1 # Executing Actions. -*- Autotest -*-
2 # Copyright (C) 2002, 2004, 2005, 2007, 2009 Free Software Foundation,
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 AT_BANNER([[User Actions.]])
21 # AT_SYNCLINES_COMPILE(FILE)
22 # --------------------------
23 # Compile FILE expecting an error, and save in the file stdout the
24 # normalized output. Ignore the exit status, since some compilers
25 # (e.g. c89 on IRIX 6.5) triger warnings on `#error', instead of
27 m4_define([AT_SYNCLINES_COMPILE],
28 [AT_CHECK([$CC $CFLAGS $CPPFLAGS -c $1], [ignore], [], [stderr])
29 # In case GCC displays column information, strip it down.
31 # input.y:4:2: #error "4" or
32 # input.y:4.2: #error "4" or
33 # input.y:4:2: error: #error "4"
35 # input.y:4: #error "4"
37 # It may also issue more context information:
39 # input.y: In function 'yyparse':
40 # input.y:8: #error "8"
42 # input.y:4: #error "8"
44 AT_CHECK([[sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' \
45 -e 's/^\([^:]*:[^:]*:\)[^@%:@]*\( @%:@error\)/\1\2/' \
46 -e "/^[^:]*: In function '[^\']*':$/d" \
51 # AT_TEST_SYNCLINE(TITLE, INPUT, ERROR-MSG)
52 # -----------------------------------------
53 # Check that compiling the parser produced from INPUT cause GCC
55 m4_define([AT_TEST_SYNCLINE],
58 # It seems impossible to find a generic scheme to check the location
59 # of an error. Even requiring GCC is not sufficient, since for instance
60 # the version modified by Apple:
62 # | Reading specs from /usr/libexec/gcc/darwin/ppc/2.95.2/specs
63 # | Apple Computer, Inc. version gcc-934.3, based on gcc version 2.95.2
64 # | 19991024 (release) configure:2124: $? = 0
68 # | input.y:2: #error "2"
73 # | cpp-precomp: warning: errors during smart preprocessing, retrying in basic mode
79 AT_SYNCLINES_COMPILE([syncline.c])
80 AT_CHECK([[test "`cat stdout`" = 'syncline.c:1: @%:@error "1"' || exit 77]])
82 AT_DATA([[input.y]], [$2])
83 AT_BISON_CHECK([-o input.c input.y])
84 AT_SYNCLINES_COMPILE([input.c])
85 AT_CHECK([cat stdout], 0, [$3])
90 ## --------------------- ##
91 ## Prologue synch line. ##
92 ## --------------------- ##
95 AT_TEST_SYNCLINE([Prologue synch line],
98 void yyerror (const char *s);
104 [input.y:2: #error "2"
108 ## ------------------- ##
109 ## %union synch line. ##
110 ## ------------------- ##
112 AT_TEST_SYNCLINE([%union synch line],
118 void yyerror (const char *s);
124 [input.y:2: #error "2"
128 ## ------------------------- ##
129 ## Postprologue synch line. ##
130 ## ------------------------- ##
132 AT_TEST_SYNCLINE([Postprologue synch line],
134 void yyerror (const char *s);
147 [input.y:10: #error "10"
151 ## ------------------- ##
152 ## Action synch line. ##
153 ## ------------------- ##
155 AT_TEST_SYNCLINE([Action synch line],
157 void yyerror (const char *s);
166 [input.y:8: #error "8"
170 ## --------------------- ##
171 ## Epilogue synch line. ##
172 ## --------------------- ##
174 AT_TEST_SYNCLINE([Epilogue synch line],
176 void yyerror (const char *s);
184 [input.y:8: #error "8"