+# It may also issue more context information:
+#
+# input.y: In function 'yyparse':
+# input.y:8: #error "8"
+# =>
+# input.y:4: #error "8"
+#
+# The message may include a caret-error:
+#
+# input.y:1:2: error: #error "1"
+# #error "1"
+# ^
+#
+# And possibly distcc adds its bits.
+#
+# distcc[33187] ERROR: compile (null) on localhost failed
+# syncline.c:1:2: error: #error "1"
+# distcc[33185] ERROR: compile syncline.c on localhost failed
+#
+# or even
+#
+# distcc[35882] (dcc_connect_by_name) ERROR: failed to look up host "chrisimac": Unknown host
+# distcc[35882] Warning: failed to distribute input.c to chrisimac/4, running locally instead
+
+AT_CHECK([[$PERL -p -0777 - stderr <<\EOF
+ s/^distcc\[\d+\] .*\n//gm;
+ s/^([^:]+:\d+)[.:][^:]+:(.+)$/$][1:$][2/gm;
+ s/^([^:]+:\d+):[^#]*( #error)/$][1:$][2/gm;
+ s/^[^:]*: In function '[^']+':\n//gm;
+ s/^\ +#error.*\n\ *\^\n//gm;
+EOF
+]],
+ 0, [stdout])
+])
+
+# AT_TEST(TITLE, INPUT, ERROR-MSG)
+# --------------------------------
+# Check that compiling the parser produced from INPUT cause GCC
+# to issue ERROR-MSG.
+m4_pushdef([AT_TEST],
+[AT_SETUP([$1])
+AT_BISON_OPTION_PUSHDEFS
+# It seems impossible to find a generic scheme to check the location
+# of an error. Even requiring GCC is not sufficient, since for instance
+# the version modified by Apple:
+#
+# | Reading specs from /usr/libexec/gcc/darwin/ppc/2.95.2/specs
+# | Apple Computer, Inc. version gcc-934.3, based on gcc version 2.95.2
+# | 19991024 (release) configure:2124: $? = 0
+#
+# instead of:
+#
+# | input.y:2: #error "2"
+#
+# it reports:
+#
+# | input.y:2: "2"
+# | cpp-precomp: warning: errors during smart preprocessing, retrying in basic mode
+
+AT_DATA([syncline.c],
+[[#error "1"
+int i; // avoids -pedantic warning about an empty translation unit
+]])
+
+AT_SYNCLINES_COMPILE([syncline.c])
+AT_CHECK([[test "`cat stdout`" = 'syncline.c:1: @%:@error "1"' || exit 77]])
+
+AT_DATA([[input.y]], [$2])
+AT_BISON_CHECK([-o input.c input.y])
+AT_SYNCLINES_COMPILE([input.c])
+AT_CHECK([cat stdout], 0, [$3])
+AT_BISON_OPTION_POPDEFS