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 2, or (at your option)
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, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
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) triger warnings on `#error', instead of
28 m4_define([AT_SYNCLINES_COMPILE],
29 [AT_CHECK([$CC $CFLAGS $CPPFLAGS -c $1], [ignore], [], [stderr])
30 # In case GCC displays column information, strip it down.
32 # input.y:4:2: #error "4" or
33 # input.y:4.2: #error "4" or
34 # input.y:4:2: error: #error "4"
36 # input.y:4: #error "4"
38 AT_CHECK([[sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^@%:@]*\( @%:@error\)/\1\2/' stderr]], 0, [stdout])
41 # AT_TEST_SYNCLINE(TITLE, INPUT, ERROR-MSG)
42 # -----------------------------------------
43 # Check that compiling the parser produced from INPUT cause GCC
45 m4_define([AT_TEST_SYNCLINE],
48 # It seems impossible to find a generic scheme to check the location
49 # of an error. Even requiring GCC is not sufficient, since for instance
50 # the version modified by Apple:
52 # | Reading specs from /usr/libexec/gcc/darwin/ppc/2.95.2/specs
53 # | Apple Computer, Inc. version gcc-934.3, based on gcc version 2.95.2
54 # | 19991024 (release) configure:2124: $? = 0
58 # | input.y:2: #error "2"
63 # | cpp-precomp: warning: errors during smart preprocessing, retrying in basic mode
69 AT_SYNCLINES_COMPILE([syncline.c])
70 AT_CHECK([[test "`cat stdout`" = 'syncline.c:1: @%:@error "1"' || exit 77]])
72 AT_DATA([[input.y]], [$2])
73 AT_CHECK([bison -o input.c input.y])
74 AT_SYNCLINES_COMPILE([input.c])
75 AT_CHECK([cat stdout], 0, [$3])
80 ## --------------------- ##
81 ## Prologue synch line. ##
82 ## --------------------- ##
85 AT_TEST_SYNCLINE([Prologue synch line],
88 void yyerror (const char *s);
94 [input.y:2: #error "2"
98 ## ------------------- ##
99 ## %union synch line. ##
100 ## ------------------- ##
102 AT_TEST_SYNCLINE([%union synch line],
108 void yyerror (const char *s);
114 [input.y:2: #error "2"
118 ## ------------------------- ##
119 ## Postprologue synch line. ##
120 ## ------------------------- ##
122 AT_TEST_SYNCLINE([Postprologue synch line],
124 void yyerror (const char *s);
137 [input.y:10: #error "10"
141 ## ------------------- ##
142 ## Action synch line. ##
143 ## ------------------- ##
145 AT_TEST_SYNCLINE([Action synch line],
147 void yyerror (const char *s);
156 [input.y:8: #error "8"
160 ## --------------------- ##
161 ## Epilogue synch line. ##
162 ## --------------------- ##
164 AT_TEST_SYNCLINE([Epilogue synch line],
166 void yyerror (const char *s);
174 [input.y:8: #error "8"