]> git.saurik.com Git - bison.git/blame_incremental - tests/synclines.at
Update gnulib.
[bison.git] / tests / synclines.at
... / ...
CommitLineData
1# Executing Actions. -*- Autotest -*-
2# Copyright (C) 2002, 2004, 2005, 2007 Free Software Foundation, Inc.
3
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.
8#
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.
13#
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/>.
16
17AT_BANNER([[User Actions.]])
18
19
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
25# errors.
26m4_define([AT_SYNCLINES_COMPILE],
27[AT_CHECK([$CC $CFLAGS $CPPFLAGS -c $1], [ignore], [], [stderr])
28# In case GCC displays column information, strip it down.
29#
30# input.y:4:2: #error "4" or
31# input.y:4.2: #error "4" or
32# input.y:4:2: error: #error "4"
33# =>
34# input.y:4: #error "4"
35#
36AT_CHECK([[sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^@%:@]*\( @%:@error\)/\1\2/' stderr]], 0, [stdout])
37])
38
39# AT_TEST_SYNCLINE(TITLE, INPUT, ERROR-MSG)
40# -----------------------------------------
41# Check that compiling the parser produced from INPUT cause GCC
42# to issue ERROR-MSG.
43m4_define([AT_TEST_SYNCLINE],
44[AT_SETUP([$1])
45
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:
49#
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
53#
54# instead of:
55#
56# | input.y:2: #error "2"
57#
58# it reports:
59#
60# | input.y:2: "2"
61# | cpp-precomp: warning: errors during smart preprocessing, retrying in basic mode
62
63AT_DATA([syncline.c],
64[[#error "1"
65]])
66
67AT_SYNCLINES_COMPILE([syncline.c])
68AT_CHECK([[test "`cat stdout`" = 'syncline.c:1: @%:@error "1"' || exit 77]])
69
70AT_DATA([[input.y]], [$2])
71AT_BISON_CHECK([-o input.c input.y])
72AT_SYNCLINES_COMPILE([input.c])
73AT_CHECK([cat stdout], 0, [$3])
74AT_CLEANUP
75])
76
77
78## --------------------- ##
79## Prologue synch line. ##
80## --------------------- ##
81
82
83AT_TEST_SYNCLINE([Prologue synch line],
84[[%{
85#error "2"
86void yyerror (const char *s);
87int yylex (void);
88%}
89%%
90exp: '0';
91]],
92[input.y:2: #error "2"
93])
94
95
96## ------------------- ##
97## %union synch line. ##
98## ------------------- ##
99
100AT_TEST_SYNCLINE([%union synch line],
101[[%union {
102#error "2"
103 char dummy;
104}
105%{
106void yyerror (const char *s);
107int yylex (void);
108%}
109%%
110exp: '0';
111]],
112[input.y:2: #error "2"
113])
114
115
116## ------------------------- ##
117## Postprologue synch line. ##
118## ------------------------- ##
119
120AT_TEST_SYNCLINE([Postprologue synch line],
121[[%{
122void yyerror (const char *s);
123int yylex (void);
124%}
125%union
126{
127 int ival;
128}
129%{
130#error "10"
131%}
132%%
133exp: '0';
134]],
135[input.y:10: #error "10"
136])
137
138
139## ------------------- ##
140## Action synch line. ##
141## ------------------- ##
142
143AT_TEST_SYNCLINE([Action synch line],
144[[%{
145void yyerror (const char *s);
146int yylex (void);
147%}
148%%
149exp:
150{
151#error "8"
152};
153]],
154[input.y:8: #error "8"
155])
156
157
158## --------------------- ##
159## Epilogue synch line. ##
160## --------------------- ##
161
162AT_TEST_SYNCLINE([Epilogue synch line],
163[[%{
164void yyerror (const char *s);
165int yylex (void);
166%}
167%%
168exp: '0';
169%%
170#error "8"
171]],
172[input.y:8: #error "8"
173])