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