]>
Commit | Line | Data |
---|---|---|
642cb8f8 | 1 | # Executing Actions. -*- Autotest -*- |
219c26ea 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 | |
25 | # (e.g. c89 on IRIX 6.5) triger warnings on `#error', instead of | |
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 | # | |
4d1801f1 | 37 | AT_CHECK([[sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^@%:@]*\( @%:@error\)/\1\2/' stderr]], 0, [stdout]) |
865b9df1 AD |
38 | ]) |
39 | ||
642cb8f8 AD |
40 | # AT_TEST_SYNCLINE(TITLE, INPUT, ERROR-MSG) |
41 | # ----------------------------------------- | |
42 | # Check that compiling the parser produced from INPUT cause GCC | |
43 | # to issue ERROR-MSG. | |
44 | m4_define([AT_TEST_SYNCLINE], | |
45 | [AT_SETUP([$1]) | |
46 | ||
865b9df1 AD |
47 | # It seems impossible to find a generic scheme to check the location |
48 | # of an error. Even requiring GCC is not sufficient, since for instance | |
49 | # the version modified by Apple: | |
50 | # | |
51 | # | Reading specs from /usr/libexec/gcc/darwin/ppc/2.95.2/specs | |
52 | # | Apple Computer, Inc. version gcc-934.3, based on gcc version 2.95.2 | |
53 | # | 19991024 (release) configure:2124: $? = 0 | |
54 | # | |
55 | # instead of: | |
56 | # | |
57 | # | input.y:2: #error "2" | |
58 | # | |
59 | # it reports: | |
60 | # | |
61 | # | input.y:2: "2" | |
62 | # | cpp-precomp: warning: errors during smart preprocessing, retrying in basic mode | |
642cb8f8 | 63 | |
865b9df1 AD |
64 | AT_DATA([syncline.c], |
65 | [[#error "1" | |
66 | ]]) | |
642cb8f8 | 67 | |
865b9df1 AD |
68 | AT_SYNCLINES_COMPILE([syncline.c]) |
69 | AT_CHECK([[test "`cat stdout`" = 'syncline.c:1: @%:@error "1"' || exit 77]]) | |
70 | ||
71 | AT_DATA([[input.y]], [$2]) | |
da730230 | 72 | AT_BISON_CHECK([-o input.c input.y]) |
865b9df1 | 73 | AT_SYNCLINES_COMPILE([input.c]) |
18493762 JD |
74 | # GCC 4.5 tells you the function within which #error appears, but |
75 | # previous versions of gcc do not. | |
76 | AT_CHECK([grep -v ': In function ' stdout], 0, [$3]) | |
642cb8f8 AD |
77 | AT_CLEANUP |
78 | ]) | |
79 | ||
80 | ||
81 | ## --------------------- ## | |
82 | ## Prologue synch line. ## | |
83 | ## --------------------- ## | |
84 | ||
85 | ||
86 | AT_TEST_SYNCLINE([Prologue synch line], | |
87 | [[%{ | |
88 | #error "2" | |
5683e9b2 AD |
89 | void yyerror (const char *s); |
90 | int yylex (void); | |
642cb8f8 AD |
91 | %} |
92 | %% | |
93 | exp: '0'; | |
94 | ]], | |
95 | [input.y:2: #error "2" | |
96 | ]) | |
97 | ||
98 | ||
99 | ## ------------------- ## | |
100 | ## %union synch line. ## | |
101 | ## ------------------- ## | |
102 | ||
103 | AT_TEST_SYNCLINE([%union synch line], | |
104 | [[%union { | |
105 | #error "2" | |
0f53f222 | 106 | char dummy; |
642cb8f8 | 107 | } |
5683e9b2 AD |
108 | %{ |
109 | void yyerror (const char *s); | |
110 | int yylex (void); | |
111 | %} | |
642cb8f8 AD |
112 | %% |
113 | exp: '0'; | |
114 | ]], | |
115 | [input.y:2: #error "2" | |
116 | ]) | |
117 | ||
118 | ||
119 | ## ------------------------- ## | |
120 | ## Postprologue synch line. ## | |
121 | ## ------------------------- ## | |
122 | ||
123 | AT_TEST_SYNCLINE([Postprologue synch line], | |
124 | [[%{ | |
5683e9b2 AD |
125 | void yyerror (const char *s); |
126 | int yylex (void); | |
642cb8f8 AD |
127 | %} |
128 | %union | |
129 | { | |
130 | int ival; | |
131 | } | |
132 | %{ | |
5683e9b2 | 133 | #error "10" |
642cb8f8 AD |
134 | %} |
135 | %% | |
136 | exp: '0'; | |
137 | ]], | |
5683e9b2 | 138 | [input.y:10: #error "10" |
642cb8f8 AD |
139 | ]) |
140 | ||
141 | ||
142 | ## ------------------- ## | |
143 | ## Action synch line. ## | |
144 | ## ------------------- ## | |
145 | ||
146 | AT_TEST_SYNCLINE([Action synch line], | |
5683e9b2 AD |
147 | [[%{ |
148 | void yyerror (const char *s); | |
149 | int yylex (void); | |
150 | %} | |
151 | %% | |
642cb8f8 AD |
152 | exp: |
153 | { | |
5683e9b2 | 154 | #error "8" |
642cb8f8 AD |
155 | }; |
156 | ]], | |
5683e9b2 | 157 | [input.y:8: #error "8" |
642cb8f8 AD |
158 | ]) |
159 | ||
160 | ||
161 | ## --------------------- ## | |
162 | ## Epilogue synch line. ## | |
163 | ## --------------------- ## | |
164 | ||
165 | AT_TEST_SYNCLINE([Epilogue synch line], | |
5683e9b2 AD |
166 | [[%{ |
167 | void yyerror (const char *s); | |
168 | int yylex (void); | |
169 | %} | |
170 | %% | |
642cb8f8 AD |
171 | exp: '0'; |
172 | %% | |
5683e9b2 | 173 | #error "8" |
642cb8f8 | 174 | ]], |
5683e9b2 | 175 | [input.y:8: #error "8" |
642cb8f8 | 176 | ]) |