]> git.saurik.com Git - bison.git/blame - tests/synclines.at
* po/id.po: New.
[bison.git] / tests / synclines.at
CommitLineData
642cb8f8 1# Executing Actions. -*- Autotest -*-
1207eeac 2# Copyright (C) 2002 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
16# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17# 02111-1307, USA.
18
19AT_BANNER([[User Actions.]])
20
865b9df1
AD
21
22# AT_SYNCLINES_COMPILE(FILE)
23# --------------------------
24# Compile FILE expecting an error, and save in the file stdout the normalized
25# output.
26m4_define([AT_SYNCLINES_COMPILE],
88ba3d33 27[AT_CHECK([$CC $CFLAGS $CPPFLAGS -c $1 || (exit 1)], 1, [], [stderr])
865b9df1
AD
28# In case GCC displays column information, strip it down.
29#
30# input.y:4:2: #error "4" or input.y:4.2: #error "4"
31# =>
32# input.y:4: #error "4"
33#
34AT_CHECK([[sed 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' stderr]], 0, [stdout])
35])
36
642cb8f8
AD
37# AT_TEST_SYNCLINE(TITLE, INPUT, ERROR-MSG)
38# -----------------------------------------
39# Check that compiling the parser produced from INPUT cause GCC
40# to issue ERROR-MSG.
41m4_define([AT_TEST_SYNCLINE],
42[AT_SETUP([$1])
43
865b9df1
AD
44# It seems impossible to find a generic scheme to check the location
45# of an error. Even requiring GCC is not sufficient, since for instance
46# the version modified by Apple:
47#
48# | Reading specs from /usr/libexec/gcc/darwin/ppc/2.95.2/specs
49# | Apple Computer, Inc. version gcc-934.3, based on gcc version 2.95.2
50# | 19991024 (release) configure:2124: $? = 0
51#
52# instead of:
53#
54# | input.y:2: #error "2"
55#
56# it reports:
57#
58# | input.y:2: "2"
59# | cpp-precomp: warning: errors during smart preprocessing, retrying in basic mode
642cb8f8 60
865b9df1
AD
61AT_DATA([syncline.c],
62[[#error "1"
63]])
642cb8f8 64
865b9df1
AD
65AT_SYNCLINES_COMPILE([syncline.c])
66AT_CHECK([[test "`cat stdout`" = 'syncline.c:1: @%:@error "1"' || exit 77]])
67
68AT_DATA([[input.y]], [$2])
642cb8f8 69AT_CHECK([bison input.y -o input.c])
865b9df1
AD
70AT_SYNCLINES_COMPILE([input.c])
71AT_CHECK([cat stdout], 0, [$3])
642cb8f8
AD
72AT_CLEANUP
73])
74
75
76## --------------------- ##
77## Prologue synch line. ##
78## --------------------- ##
79
80
81AT_TEST_SYNCLINE([Prologue synch line],
82[[%{
83#error "2"
5683e9b2
AD
84void yyerror (const char *s);
85int yylex (void);
642cb8f8
AD
86%}
87%%
88exp: '0';
89]],
90[input.y:2: #error "2"
91])
92
93
94## ------------------- ##
95## %union synch line. ##
96## ------------------- ##
97
98AT_TEST_SYNCLINE([%union synch line],
99[[%union {
100#error "2"
101}
5683e9b2
AD
102%{
103void yyerror (const char *s);
104int yylex (void);
105%}
642cb8f8
AD
106%%
107exp: '0';
108]],
109[input.y:2: #error "2"
110])
111
112
113## ------------------------- ##
114## Postprologue synch line. ##
115## ------------------------- ##
116
117AT_TEST_SYNCLINE([Postprologue synch line],
118[[%{
5683e9b2
AD
119void yyerror (const char *s);
120int yylex (void);
642cb8f8
AD
121%}
122%union
123{
124 int ival;
125}
126%{
5683e9b2 127#error "10"
642cb8f8
AD
128%}
129%%
130exp: '0';
131]],
5683e9b2 132[input.y:10: #error "10"
642cb8f8
AD
133])
134
135
136## ------------------- ##
137## Action synch line. ##
138## ------------------- ##
139
140AT_TEST_SYNCLINE([Action synch line],
5683e9b2
AD
141[[%{
142void yyerror (const char *s);
143int yylex (void);
144%}
145%%
642cb8f8
AD
146exp:
147{
5683e9b2 148#error "8"
642cb8f8
AD
149};
150]],
5683e9b2 151[input.y:8: #error "8"
642cb8f8
AD
152])
153
154
155## --------------------- ##
156## Epilogue synch line. ##
157## --------------------- ##
158
159AT_TEST_SYNCLINE([Epilogue synch line],
5683e9b2
AD
160[[%{
161void yyerror (const char *s);
162int yylex (void);
163%}
164%%
642cb8f8
AD
165exp: '0';
166%%
5683e9b2 167#error "8"
642cb8f8 168]],
5683e9b2 169[input.y:8: #error "8"
642cb8f8 170])