]>
Commit | Line | Data |
---|---|---|
642cb8f8 | 1 | # Executing Actions. -*- Autotest -*- |
1462fcee JD |
2 | # Copyright (C) 2002, 2004-2005, 2007, 2009-2010 Free Software |
3 | # Foundation, Inc. | |
642cb8f8 | 4 | |
f16b0819 | 5 | # This program is free software: you can redistribute it and/or modify |
642cb8f8 | 6 | # it under the terms of the GNU General Public License as published by |
f16b0819 PE |
7 | # the Free Software Foundation, either version 3 of the License, or |
8 | # (at your option) any later version. | |
9 | # | |
642cb8f8 AD |
10 | # This program is distributed in the hope that it will be useful, |
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | # GNU General Public License for more details. | |
f16b0819 | 14 | # |
642cb8f8 | 15 | # You should have received a copy of the GNU General Public License |
f16b0819 | 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
642cb8f8 AD |
17 | |
18 | AT_BANNER([[User Actions.]]) | |
19 | ||
865b9df1 AD |
20 | |
21 | # AT_SYNCLINES_COMPILE(FILE) | |
22 | # -------------------------- | |
4e8d992c AD |
23 | # Compile FILE expecting an error, and save in the file stdout the |
24 | # normalized output. Ignore the exit status, since some compilers | |
bdc360ae | 25 | # (e.g. c89 on IRIX 6.5) trigger warnings on `#error', instead of |
4e8d992c | 26 | # errors. |
865b9df1 | 27 | m4_define([AT_SYNCLINES_COMPILE], |
f32b346d | 28 | [AT_CHECK([$CC $CFLAGS $CPPFLAGS -c $1], [ignore], [], [stderr]) |
865b9df1 AD |
29 | # In case GCC displays column information, strip it down. |
30 | # | |
4d1801f1 PE |
31 | # input.y:4:2: #error "4" or |
32 | # input.y:4.2: #error "4" or | |
33 | # input.y:4:2: error: #error "4" | |
865b9df1 AD |
34 | # => |
35 | # input.y:4: #error "4" | |
36 | # | |
bdc360ae AD |
37 | # It may also issue more context information: |
38 | # | |
39 | # input.y: In function 'yyparse': | |
40 | # input.y:8: #error "8" | |
41 | # => | |
42 | # input.y:4: #error "8" | |
43 | # | |
44 | # | |
45 | # And possibly distcc adds its bits. | |
46 | # | |
47 | # distcc[33187] ERROR: compile (null) on localhost failed | |
48 | # syncline.c:1:2: error: #error "1" | |
49 | # distcc[33185] ERROR: compile syncline.c on localhost failed | |
50 | # | |
51 | # or even | |
52 | # | |
53 | # distcc[35882] (dcc_connect_by_name) ERROR: failed to look up host "chrisimac": Unknown host | |
54 | # distcc[35882] Warning: failed to distribute input.c to chrisimac/4, running locally instead | |
55 | ||
56 | AT_CHECK([[sed -e '/^distcc\[[0-9]*\] /d' \ | |
57 | -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' \ | |
58 | -e 's/^\([^:]*:[^:]*:\)[^@%:@]*\( @%:@error\)/\1\2/' \ | |
59 | -e "/^[^:]*: In function '[^\']*':$/d" \ | |
60 | stderr]], | |
61 | 0, [stdout]) | |
865b9df1 AD |
62 | ]) |
63 | ||
642cb8f8 AD |
64 | # AT_TEST_SYNCLINE(TITLE, INPUT, ERROR-MSG) |
65 | # ----------------------------------------- | |
66 | # Check that compiling the parser produced from INPUT cause GCC | |
67 | # to issue ERROR-MSG. | |
68 | m4_define([AT_TEST_SYNCLINE], | |
69 | [AT_SETUP([$1]) | |
70 | ||
865b9df1 AD |
71 | # It seems impossible to find a generic scheme to check the location |
72 | # of an error. Even requiring GCC is not sufficient, since for instance | |
73 | # the version modified by Apple: | |
74 | # | |
75 | # | Reading specs from /usr/libexec/gcc/darwin/ppc/2.95.2/specs | |
76 | # | Apple Computer, Inc. version gcc-934.3, based on gcc version 2.95.2 | |
77 | # | 19991024 (release) configure:2124: $? = 0 | |
78 | # | |
79 | # instead of: | |
80 | # | |
81 | # | input.y:2: #error "2" | |
82 | # | |
83 | # it reports: | |
84 | # | |
85 | # | input.y:2: "2" | |
86 | # | cpp-precomp: warning: errors during smart preprocessing, retrying in basic mode | |
642cb8f8 | 87 | |
865b9df1 AD |
88 | AT_DATA([syncline.c], |
89 | [[#error "1" | |
90 | ]]) | |
642cb8f8 | 91 | |
865b9df1 AD |
92 | AT_SYNCLINES_COMPILE([syncline.c]) |
93 | AT_CHECK([[test "`cat stdout`" = 'syncline.c:1: @%:@error "1"' || exit 77]]) | |
94 | ||
95 | AT_DATA([[input.y]], [$2]) | |
da730230 | 96 | AT_BISON_CHECK([-o input.c input.y]) |
865b9df1 | 97 | AT_SYNCLINES_COMPILE([input.c]) |
bdc360ae | 98 | AT_CHECK([cat stdout], 0, [$3]) |
642cb8f8 AD |
99 | AT_CLEANUP |
100 | ]) | |
101 | ||
102 | ||
103 | ## --------------------- ## | |
104 | ## Prologue synch line. ## | |
105 | ## --------------------- ## | |
106 | ||
107 | ||
108 | AT_TEST_SYNCLINE([Prologue synch line], | |
109 | [[%{ | |
110 | #error "2" | |
5683e9b2 AD |
111 | void yyerror (const char *s); |
112 | int yylex (void); | |
642cb8f8 AD |
113 | %} |
114 | %% | |
115 | exp: '0'; | |
116 | ]], | |
117 | [input.y:2: #error "2" | |
118 | ]) | |
119 | ||
120 | ||
121 | ## ------------------- ## | |
122 | ## %union synch line. ## | |
123 | ## ------------------- ## | |
124 | ||
125 | AT_TEST_SYNCLINE([%union synch line], | |
126 | [[%union { | |
127 | #error "2" | |
0f53f222 | 128 | char dummy; |
642cb8f8 | 129 | } |
5683e9b2 AD |
130 | %{ |
131 | void yyerror (const char *s); | |
132 | int yylex (void); | |
133 | %} | |
642cb8f8 AD |
134 | %% |
135 | exp: '0'; | |
136 | ]], | |
137 | [input.y:2: #error "2" | |
138 | ]) | |
139 | ||
140 | ||
141 | ## ------------------------- ## | |
142 | ## Postprologue synch line. ## | |
143 | ## ------------------------- ## | |
144 | ||
145 | AT_TEST_SYNCLINE([Postprologue synch line], | |
146 | [[%{ | |
5683e9b2 AD |
147 | void yyerror (const char *s); |
148 | int yylex (void); | |
642cb8f8 AD |
149 | %} |
150 | %union | |
151 | { | |
152 | int ival; | |
153 | } | |
154 | %{ | |
5683e9b2 | 155 | #error "10" |
642cb8f8 AD |
156 | %} |
157 | %% | |
158 | exp: '0'; | |
159 | ]], | |
5683e9b2 | 160 | [input.y:10: #error "10" |
642cb8f8 AD |
161 | ]) |
162 | ||
163 | ||
164 | ## ------------------- ## | |
165 | ## Action synch line. ## | |
166 | ## ------------------- ## | |
167 | ||
168 | AT_TEST_SYNCLINE([Action synch line], | |
5683e9b2 AD |
169 | [[%{ |
170 | void yyerror (const char *s); | |
171 | int yylex (void); | |
172 | %} | |
173 | %% | |
642cb8f8 AD |
174 | exp: |
175 | { | |
5683e9b2 | 176 | #error "8" |
642cb8f8 AD |
177 | }; |
178 | ]], | |
5683e9b2 | 179 | [input.y:8: #error "8" |
642cb8f8 AD |
180 | ]) |
181 | ||
182 | ||
183 | ## --------------------- ## | |
184 | ## Epilogue synch line. ## | |
185 | ## --------------------- ## | |
186 | ||
187 | AT_TEST_SYNCLINE([Epilogue synch line], | |
5683e9b2 AD |
188 | [[%{ |
189 | void yyerror (const char *s); | |
190 | int yylex (void); | |
191 | %} | |
192 | %% | |
642cb8f8 AD |
193 | exp: '0'; |
194 | %% | |
5683e9b2 | 195 | #error "8" |
642cb8f8 | 196 | ]], |
5683e9b2 | 197 | [input.y:8: #error "8" |
642cb8f8 | 198 | ]) |