diff --git a/job.c b/job.c
index 80e63d25..5ad2b7f0 100644
--- a/job.c
+++ b/job.c
@@ -553,8 +553,11 @@ child_error (struct child *child,
     nm = _("<builtin>");
   else
     {
-      char *a = alloca (strlen (flocp->filenm) + 1 + 11 + 1);
-      sprintf (a, "%s:%lu", flocp->filenm, flocp->lineno + flocp->offset);
+      /* We can't use the standard <FILE>:<LINENO> syntax here because
+         Emacs misinterprets it and matches a bogus filename in the compile
+         buffer.  */
+      char *a = alloca (strlen (flocp->filenm) + 6 + INTSTR_LENGTH + 1);
+      sprintf (a, "%s;%lu", flocp->filenm, flocp->lineno + flocp->offset);
       nm = a;
     }
 
diff --git a/tests/scripts/features/errors b/tests/scripts/features/errors
index ebd43831..5c570790 100644
--- a/tests/scripts/features/errors
+++ b/tests/scripts/features/errors
@@ -50,7 +50,7 @@ $delete_error_code = $? >> 8;
 
 $answer = "$rm_command cleanit
 $cleanit_error
-$make_name: [$makefile:2: clean] Error $delete_error_code (ignored)
+$make_name: [$makefile;2: clean] Error $delete_error_code (ignored)
 $rm_command foo\n";
 
 &run_make_with_options($makefile,"",&get_logfile);
@@ -77,7 +77,7 @@ if (!$vos)
 
 $answer = "$rm_command cleanit
 $cleanit_error
-$make_name: [$makefile:5: clean2] Error $delete_error_code (ignored)
+$make_name: [$makefile;5: clean2] Error $delete_error_code (ignored)
 $rm_command foo\n";
 
 &run_make_with_options($makefile,"clean2 -i",&get_logfile);
@@ -98,7 +98,7 @@ all:
 	@echo there
 	@exit 1
 !,
-              '', "hi\nthere\n#MAKE#: *** [#MAKEFILE#:5: all] Error 1", 512);
+              '', "hi\nthere\n#MAKE#: *** [#MAKEFILE#;5: all] Error 1", 512);
 
 1;
 
diff --git a/tests/scripts/features/include b/tests/scripts/features/include
index 0c63c067..3df5af0b 100644
--- a/tests/scripts/features/include
+++ b/tests/scripts/features/include
@@ -221,7 +221,7 @@ include inc1
 inc1: foo; echo > $@
 foo:; exit 1
 !,
-                  '', "exit 1\n#MAKEFILE#:3: inc1: $ERR_no_such_file\n#MAKE#: *** [#MAKEFILE#:5: foo] Error 1\n", 512);
+                  '', "exit 1\n#MAKEFILE#:3: inc1: $ERR_no_such_file\n#MAKE#: *** [#MAKEFILE#;5: foo] Error 1\n", 512);
 
     rmfiles('inc1');
 
diff --git a/tests/scripts/features/output-sync b/tests/scripts/features/output-sync
index 914b381e..1407e81a 100644
--- a/tests/scripts/features/output-sync
+++ b/tests/scripts/features/output-sync
@@ -206,9 +206,9 @@ bar: end
 #MAKE#[1]: Entering directory '#PWD#/foo'
 foo-fail: start
 foo-fail: end
-#MAKE#[1]: *** [Makefile:23: foo-fail] Error 1
+#MAKE#[1]: *** [Makefile;23: foo-fail] Error 1
 #MAKE#[1]: Leaving directory '#PWD#/foo'
-#MAKE#: *** [#MAKEFILE#:4: make-foo-fail] Error 2\n",
+#MAKE#: *** [#MAKEFILE#;4: make-foo-fail] Error 2\n",
 512);
 
 # Test the per-job synchronization.
@@ -326,7 +326,7 @@ run_make_test(qq!
 all: t1
 t1: ; -\@\$(MAKE) -f $m1
 !,
-              "-j -Oline", "#MAKE#[1]: Entering directory '#PWD#'\nd1 stderr\nd1 stdout\n$m1:3: *** d1 failed.  Stop.\n#MAKE#[1]: Leaving directory '#PWD#'\n#MAKE#: [#MAKEFILE#:3: t1] Error 2 (ignored)\n");
+              "-j -Oline", "#MAKE#[1]: Entering directory '#PWD#'\nd1 stderr\nd1 stdout\n$m1:3: *** d1 failed.  Stop.\n#MAKE#[1]: Leaving directory '#PWD#'\n#MAKE#: [#MAKEFILE#;3: t1] Error 2 (ignored)\n");
 
 rmfiles($m1);
 
@@ -343,7 +343,7 @@ if ($port_type ne 'W32') {
     run_make_test(q!
 all:: ; @./foo bar baz
 !,
-              '-O', "#MAKE#: ./foo: Command not found\n#MAKE#: *** [#MAKEFILE#:2: all] Error 127\n", 512);
+              '-O', "#MAKE#: ./foo: Command not found\n#MAKE#: *** [#MAKEFILE#;2: all] Error 127\n", 512);
 }
 
 # This tells the test driver that the perl test script executed properly.
diff --git a/tests/scripts/features/parallelism b/tests/scripts/features/parallelism
index fabe5485..b12532d6 100644
--- a/tests/scripts/features/parallelism
+++ b/tests/scripts/features/parallelism
@@ -99,12 +99,12 @@ ok:
 	\@$sleep_command 4
 	\@echo Ok done",
               '-rR -j5', "Fail
-#MAKE#: *** [#MAKEFILE#:8: fail.1] Error 1
+#MAKE#: *** [#MAKEFILE#;8: fail.1] Error 1
 #MAKE#: *** Waiting for unfinished jobs....
 Fail
-#MAKE#: *** [#MAKEFILE#:8: fail.2] Error 1
+#MAKE#: *** [#MAKEFILE#;8: fail.2] Error 1
 Fail
-#MAKE#: *** [#MAKEFILE#:8: fail.3] Error 1
+#MAKE#: *** [#MAKEFILE#;8: fail.3] Error 1
 Ok done",
              512);
 
diff --git a/tests/scripts/features/patternrules b/tests/scripts/features/patternrules
index 8f7ccc40..f76724eb 100644
--- a/tests/scripts/features/patternrules
+++ b/tests/scripts/features/patternrules
@@ -110,7 +110,7 @@ $(dir)/foo.bar:
 
 ',
 "dir=$dir",
-"#MAKE#: *** [#MAKEFILE#:6: $dir/foo.bar] Error 1",
+"#MAKE#: *** [#MAKEFILE#;6: $dir/foo.bar] Error 1",
 512);
 
 unlink("$dir/foo.bar");
diff --git a/tests/scripts/features/vpathplus b/tests/scripts/features/vpathplus
index b4857171..8e723fed 100644
--- a/tests/scripts/features/vpathplus
+++ b/tests/scripts/features/vpathplus
@@ -83,7 +83,7 @@ cat ${VP}foo.c bar.c > foo.b 2>/dev/null || exit 1
 
 $answer = "not creating notarget.c from notarget.d
 cat notarget.c > notarget.b 2>/dev/null || exit 1
-$make_name: *** [$makefile:13: notarget.b] Error 1
+$make_name: *** [$makefile;13: notarget.b] Error 1
 ";
 
 &compare_output($answer,&get_logfile(1));
diff --git a/tests/scripts/misc/general3 b/tests/scripts/misc/general3
index 7bbff1c2..da9263a2 100644
--- a/tests/scripts/misc/general3
+++ b/tests/scripts/misc/general3
@@ -310,6 +310,6 @@ foo     bar
 hi
 foo     bar');
 
-run_make_test('x:;@-exit 1', '', "#MAKE#: [#MAKEFILE#:1: x] Error 1 (ignored)\n");
+run_make_test('x:;@-exit 1', '', "#MAKE#: [#MAKEFILE#;1: x] Error 1 (ignored)\n");
 
 1;
diff --git a/tests/scripts/options/dash-k b/tests/scripts/options/dash-k
index cd78e7f0..24743274 100644
--- a/tests/scripts/options/dash-k
+++ b/tests/scripts/options/dash-k
@@ -92,7 +92,7 @@ close(MAKEFILE);
 &run_make_with_options($makefile2, "-k", &get_logfile, $error_code);
 
 $answer = "exit 1
-$make_name: *** [$makefile2:9: foo.o] Error 1
+$make_name: *** [$makefile2;9: foo.o] Error 1
 $make_name: Target 'all' not remade because of errors.\n";
 
 &compare_output($answer, &get_logfile(1));
diff --git a/tests/scripts/targets/DELETE_ON_ERROR b/tests/scripts/targets/DELETE_ON_ERROR
index f0d9f9b4..6d60287e 100644
--- a/tests/scripts/targets/DELETE_ON_ERROR
+++ b/tests/scripts/targets/DELETE_ON_ERROR
@@ -8,7 +8,7 @@ run_make_test('
 .DELETE_ON_ERROR:
 all: ; exit 1 > $@
 ',
-              '', "exit 1 > all\n#MAKE#: *** [#MAKEFILE#:3: all] Error 1\n#MAKE#: *** Deleting file 'all'", 512);
+              '', "exit 1 > all\n#MAKE#: *** [#MAKEFILE#;3: all] Error 1\n#MAKE#: *** Deleting file 'all'", 512);
 
 run_make_test('
 .DELETE_ON_ERROR:
@@ -16,7 +16,7 @@ all: foo.x ;
 %.x : %.q ; echo > $@
 %.q : ; exit 1 > $@
 ',
-              '', "exit 1 > foo.q\n#MAKE#: *** [#MAKEFILE#:5: foo.q] Error 1\n#MAKE#: *** Deleting file 'foo.q'", 512);
+              '', "exit 1 > foo.q\n#MAKE#: *** [#MAKEFILE#;5: foo.q] Error 1\n#MAKE#: *** Deleting file 'foo.q'", 512);
 
 # This tells the test driver that the perl test script executed properly.
 1;
diff --git a/tests/scripts/targets/POSIX b/tests/scripts/targets/POSIX
index c44cc500..b547e491 100644
--- a/tests/scripts/targets/POSIX
+++ b/tests/scripts/targets/POSIX
@@ -17,7 +17,7 @@ run_make_test(qq!
 .POSIX:
 all: ; \@$script
 !,
-              '', "#MAKE#: *** [#MAKEFILE#:3: all] Error $err\n", 512);
+              '', "#MAKE#: *** [#MAKEFILE#;3: all] Error $err\n", 512);
 
 # User settings must override .POSIX
 $flags = '-xc';
diff --git a/tests/scripts/variables/SHELL b/tests/scripts/variables/SHELL
index 3cf6cee4..503b96e7 100644
--- a/tests/scripts/variables/SHELL
+++ b/tests/scripts/variables/SHELL
@@ -102,6 +102,6 @@ run_make_test(qq!
 .SHELLFLAGS = $flags
 all: ; \@$script
 !,
-              '', "$out#MAKE#: *** [#MAKEFILE#:3: all] Error $err\n", 512);
+              '', "$out#MAKE#: *** [#MAKEFILE#;3: all] Error $err\n", 512);
 
 1;