1 # Executing Actions. -*- Autotest -*-
3 # Copyright (C) 2002, 2004-2005, 2007, 2009-2012 Free Software
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 AT_BANNER([[User Actions.]])
22 # AT_SYNCLINES_COMPILE(FILE)
23 # --------------------------
24 # Compile FILE expecting an error, and save in the file stdout the
25 # normalized output. Ignore the exit status, since some compilers
26 # (e.g. c89 on IRIX 6.5) trigger warnings on `#error', instead of
28 m4_define([AT_SYNCLINES_COMPILE],
29 [AT_CHECK([$CC $CFLAGS $CPPFLAGS -c $1], [ignore], [], [stderr])
31 # Transform stderr into something like this:
33 # input.y:4: #error "4"
35 # In case GCC displays column information, strip it down.
37 # input.y:4:2: #error "4" or
38 # input.y:4.2: #error "4" or
39 # input.y:4:2: error: #error "4"
41 # input.y:4: #error "4"
43 # It may also issue more context information:
45 # input.y: In function 'yyparse':
46 # input.y:8: #error "8"
48 # input.y:4: #error "8"
50 # The message may include a caret-error:
52 # input.y:1:2: error: #error "1"
56 # And possibly distcc adds its bits.
58 # distcc[33187] ERROR: compile (null) on localhost failed
59 # syncline.c:1:2: error: #error "1"
60 # distcc[33185] ERROR: compile syncline.c on localhost failed
64 # distcc[35882] (dcc_connect_by_name) ERROR: failed to look up host "chrisimac": Unknown host
65 # distcc[35882] Warning: failed to distribute input.c to chrisimac/4, running locally instead
67 AT_CHECK([[perl -p -0777 - stderr <<\EOF
68 s/^distcc\[\d+\] .*\n//gm;
69 s/^([^:]+:\d+)[.:][^:]+:(.+)$/$][1:$][2/gm;
70 s/^([^:]+:\d+):[^#]*( #error)/$][1:$][2/gm;
71 s/^[^:]*: In function '[^']+':\n//gm;
72 s/^\ +#error.*\n\ *\^\n//gm;
78 # AT_TEST(TITLE, INPUT, ERROR-MSG)
79 # --------------------------------
80 # Check that compiling the parser produced from INPUT cause GCC
84 AT_BISON_OPTION_PUSHDEFS
85 # It seems impossible to find a generic scheme to check the location
86 # of an error. Even requiring GCC is not sufficient, since for instance
87 # the version modified by Apple:
89 # | Reading specs from /usr/libexec/gcc/darwin/ppc/2.95.2/specs
90 # | Apple Computer, Inc. version gcc-934.3, based on gcc version 2.95.2
91 # | 19991024 (release) configure:2124: $? = 0
95 # | input.y:2: #error "2"
100 # | cpp-precomp: warning: errors during smart preprocessing, retrying in basic mode
102 AT_DATA([syncline.c],
104 int i; // avoids -pedantic warning about an empty translation unit
107 AT_SYNCLINES_COMPILE([syncline.c])
108 AT_CHECK([[test "`cat stdout`" = 'syncline.c:1: @%:@error "1"' || exit 77]])
110 AT_DATA([[input.y]], [$2])
111 AT_BISON_CHECK([-o input.c input.y])
112 AT_SYNCLINES_COMPILE([input.c])
113 AT_CHECK([cat stdout], 0, [$3])
114 AT_BISON_OPTION_POPDEFS
119 ## --------------------- ##
120 ## Prologue synch line. ##
121 ## --------------------- ##
124 AT_TEST([Prologue synch line],
127 ]AT_YYERROR_DECLARE_EXTERN[
128 ]AT_YYLEX_DECLARE_EXTERN[
134 [input.y:2: #error "2"
138 ## ------------------- ##
139 ## %union synch line. ##
140 ## ------------------- ##
142 AT_TEST([%union synch line],
148 ]AT_YYERROR_DECLARE_EXTERN[
149 ]AT_YYLEX_DECLARE_EXTERN[
155 [input.y:2: #error "2"
159 ## ------------------------- ##
160 ## Postprologue synch line. ##
161 ## ------------------------- ##
163 AT_TEST([Postprologue synch line],
165 ]AT_YYERROR_DECLARE_EXTERN[
166 ]AT_YYLEX_DECLARE_EXTERN[
179 [input.y:10: #error "10"
183 ## ------------------- ##
184 ## Action synch line. ##
185 ## ------------------- ##
187 AT_TEST([Action synch line],
189 ]AT_YYERROR_DECLARE_EXTERN[
190 ]AT_YYLEX_DECLARE_EXTERN[
198 [input.y:8: #error "8"
202 ## --------------------- ##
203 ## Epilogue synch line. ##
204 ## --------------------- ##
206 AT_TEST([Epilogue synch line],
208 ]AT_YYERROR_DECLARE_EXTERN[
209 ]AT_YYLEX_DECLARE_EXTERN[
216 [input.y:8: #error "8"