]> git.saurik.com Git - bison.git/blame - tests/synclines.at
* tests/calc.at: Exercise prologue splitting.
[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
21# AT_TEST_SYNCLINE(TITLE, INPUT, ERROR-MSG)
22# -----------------------------------------
23# Check that compiling the parser produced from INPUT cause GCC
24# to issue ERROR-MSG.
25m4_define([AT_TEST_SYNCLINE],
26[AT_SETUP([$1])
27
28# I'm not sure I can find a generic scheme to check the location
29# of an error, so we keep this for GCC only.
30AT_CHECK([test "$GCC" = yes || exit 77])
31
32AT_DATA([[input.y]],
33[$2])
34
35AT_CHECK([bison input.y -o input.c])
1207eeac
AD
36AT_CHECK([$CC $CFLAGS $CPPFLAGS input.c -o input], 1, [], [stderr])
37# In case GCC displays column information, strip it down.
38#
39# input.y:4:2: #error "4" or input.y:4.2: #error "4"
40# =>
41# input.y:4: #error "4"
42#
43AT_CHECK([[sed 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' stderr]],
44 0, [$3])
642cb8f8
AD
45AT_CLEANUP
46])
47
48
49## --------------------- ##
50## Prologue synch line. ##
51## --------------------- ##
52
53
54AT_TEST_SYNCLINE([Prologue synch line],
55[[%{
56#error "2"
57%}
58%%
59exp: '0';
60]],
61[input.y:2: #error "2"
62])
63
64
65## ------------------- ##
66## %union synch line. ##
67## ------------------- ##
68
69AT_TEST_SYNCLINE([%union synch line],
70[[%union {
71#error "2"
72}
73%%
74exp: '0';
75]],
76[input.y:2: #error "2"
77])
78
79
80## ------------------------- ##
81## Postprologue synch line. ##
82## ------------------------- ##
83
84AT_TEST_SYNCLINE([Postprologue synch line],
85[[%{
86/* Nothing here. */
87%}
88%union
89{
90 int ival;
91}
92%{
93#error "9"
94%}
95%%
96exp: '0';
97]],
98[input.y:9: #error "9"
99])
100
101
102## ------------------- ##
103## Action synch line. ##
104## ------------------- ##
105
106AT_TEST_SYNCLINE([Action synch line],
107[[%%
108exp:
109{
110#error "4"
111};
112]],
113[input.y:4: #error "4"
114])
115
116
117## --------------------- ##
118## Epilogue synch line. ##
119## --------------------- ##
120
121AT_TEST_SYNCLINE([Epilogue synch line],
122[[%%
123exp: '0';
124%%
125#error "4"
126]],
127[input.y:4: #error "4"
128])