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