]> git.saurik.com Git - bison.git/blob - tests/synclines.at
* src/output.c (output_rule_data): Fix various range errors:
[bison.git] / tests / synclines.at
1 # Executing Actions. -*- Autotest -*-
2 # Copyright 2002 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 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
19 AT_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.
25 m4_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.
30 AT_CHECK([test "$GCC" = yes || exit 77])
31
32 AT_DATA([[input.y]],
33 [$2])
34
35 AT_CHECK([bison input.y -o input.c])
36 AT_CHECK([$CC $CFLAGS $CPPFLAGS input.c -o input], 1, [], [$3])
37 AT_CLEANUP
38 ])
39
40
41 ## --------------------- ##
42 ## Prologue synch line. ##
43 ## --------------------- ##
44
45
46 AT_TEST_SYNCLINE([Prologue synch line],
47 [[%{
48 #error "2"
49 %}
50 %%
51 exp: '0';
52 ]],
53 [input.y:2: #error "2"
54 ])
55
56
57 ## ------------------- ##
58 ## %union synch line. ##
59 ## ------------------- ##
60
61 AT_TEST_SYNCLINE([%union synch line],
62 [[%union {
63 #error "2"
64 }
65 %%
66 exp: '0';
67 ]],
68 [input.y:2: #error "2"
69 ])
70
71
72 ## ------------------------- ##
73 ## Postprologue synch line. ##
74 ## ------------------------- ##
75
76 AT_TEST_SYNCLINE([Postprologue synch line],
77 [[%{
78 /* Nothing here. */
79 %}
80 %union
81 {
82 int ival;
83 }
84 %{
85 #error "9"
86 %}
87 %%
88 exp: '0';
89 ]],
90 [input.y:9: #error "9"
91 ])
92
93
94 ## ------------------- ##
95 ## Action synch line. ##
96 ## ------------------- ##
97
98 AT_TEST_SYNCLINE([Action synch line],
99 [[%%
100 exp:
101 {
102 #error "4"
103 };
104 ]],
105 [input.y:4: #error "4"
106 ])
107
108
109 ## --------------------- ##
110 ## Epilogue synch line. ##
111 ## --------------------- ##
112
113 AT_TEST_SYNCLINE([Epilogue synch line],
114 [[%%
115 exp: '0';
116 %%
117 #error "4"
118 ]],
119 [input.y:4: #error "4"
120 ])