1 # Executing Actions. -*- Autotest -*-
2 # Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 AT_BANNER([[User Actions.]])
20 # AT_SYNCLINES_COMPILE(FILE)
21 # --------------------------
22 # Compile FILE expecting an error, and save in the file stdout the
23 # normalized output. Ignore the exit status, since some compilers
24 # (e.g. c89 on IRIX 6.5) triger warnings on `#error', instead of
26 m4_define([AT_SYNCLINES_COMPILE],
27 [AT_CHECK([$CC $CFLAGS $CPPFLAGS -c $1], [ignore], [], [stderr])
28 # In case GCC displays column information, strip it down.
30 # input.y:4:2: #error "4" or
31 # input.y:4.2: #error "4" or
32 # input.y:4:2: error: #error "4"
34 # input.y:4: #error "4"
36 AT_CHECK([[sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^@%:@]*\( @%:@error\)/\1\2/' stderr]], 0, [stdout])
39 # AT_TEST_SYNCLINE(TITLE, INPUT, ERROR-MSG)
40 # -----------------------------------------
41 # Check that compiling the parser produced from INPUT cause GCC
43 m4_define([AT_TEST_SYNCLINE],
46 # It seems impossible to find a generic scheme to check the location
47 # of an error. Even requiring GCC is not sufficient, since for instance
48 # the version modified by Apple:
50 # | Reading specs from /usr/libexec/gcc/darwin/ppc/2.95.2/specs
51 # | Apple Computer, Inc. version gcc-934.3, based on gcc version 2.95.2
52 # | 19991024 (release) configure:2124: $? = 0
56 # | input.y:2: #error "2"
61 # | cpp-precomp: warning: errors during smart preprocessing, retrying in basic mode
67 AT_SYNCLINES_COMPILE([syncline.c])
68 AT_CHECK([[test "`cat stdout`" = 'syncline.c:1: @%:@error "1"' || exit 77]])
70 AT_DATA([[input.y]], [$2])
71 AT_CHECK([bison -o input.c input.y])
72 AT_SYNCLINES_COMPILE([input.c])
73 AT_CHECK([cat stdout], 0, [$3])
78 ## --------------------- ##
79 ## Prologue synch line. ##
80 ## --------------------- ##
83 AT_TEST_SYNCLINE([Prologue synch line],
86 void yyerror (const char *s);
92 [input.y:2: #error "2"
96 ## ------------------- ##
97 ## %union synch line. ##
98 ## ------------------- ##
100 AT_TEST_SYNCLINE([%union synch line],
106 void yyerror (const char *s);
112 [input.y:2: #error "2"
116 ## ------------------------- ##
117 ## Postprologue synch line. ##
118 ## ------------------------- ##
120 AT_TEST_SYNCLINE([Postprologue synch line],
122 void yyerror (const char *s);
135 [input.y:10: #error "10"
139 ## ------------------- ##
140 ## Action synch line. ##
141 ## ------------------- ##
143 AT_TEST_SYNCLINE([Action synch line],
145 void yyerror (const char *s);
154 [input.y:8: #error "8"
158 ## --------------------- ##
159 ## Epilogue synch line. ##
160 ## --------------------- ##
162 AT_TEST_SYNCLINE([Epilogue synch line],
164 void yyerror (const char *s);
172 [input.y:8: #error "8"