diff --git a/src/complain.c b/src/complain.c
index ced908e3..87563d59 100644
--- a/src/complain.c
+++ b/src/complain.c
@@ -425,7 +425,7 @@ error_message (const location *loc, int *indent, warnings flags,
if (loc)
pos += location_print (*loc, stderr);
else
- pos += fprintf (stderr, "%s", current_file ? current_file : program_name);
+ pos += fprintf (stderr, "%s", grammar_file ? grammar_file : program_name);
pos += fprintf (stderr, ": ");
if (indent)
diff --git a/tests/diagnostics.at b/tests/diagnostics.at
index 96d7e224..70ba63fb 100644
--- a/tests/diagnostics.at
+++ b/tests/diagnostics.at
@@ -229,7 +229,7 @@ b: {}
| %empty
/dev/stdout:1.4-5: warning: empty rule without %empty [-Wempty-rule]
| %empty
-/dev/stdout: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
+input.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
]])