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