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