]>
Commit | Line | Data |
---|---|---|
1 | # Executing Actions. -*- Autotest -*- | |
2 | # Copyright (C) 2002 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 | } | |
104 | %{ | |
105 | void yyerror (const char *s); | |
106 | int yylex (void); | |
107 | %} | |
108 | %% | |
109 | exp: '0'; | |
110 | ]], | |
111 | [input.y:2: #error "2" | |
112 | ]) | |
113 | ||
114 | ||
115 | ## ------------------------- ## | |
116 | ## Postprologue synch line. ## | |
117 | ## ------------------------- ## | |
118 | ||
119 | AT_TEST_SYNCLINE([Postprologue synch line], | |
120 | [[%{ | |
121 | void yyerror (const char *s); | |
122 | int yylex (void); | |
123 | %} | |
124 | %union | |
125 | { | |
126 | int ival; | |
127 | } | |
128 | %{ | |
129 | #error "10" | |
130 | %} | |
131 | %% | |
132 | exp: '0'; | |
133 | ]], | |
134 | [input.y:10: #error "10" | |
135 | ]) | |
136 | ||
137 | ||
138 | ## ------------------- ## | |
139 | ## Action synch line. ## | |
140 | ## ------------------- ## | |
141 | ||
142 | AT_TEST_SYNCLINE([Action synch line], | |
143 | [[%{ | |
144 | void yyerror (const char *s); | |
145 | int yylex (void); | |
146 | %} | |
147 | %% | |
148 | exp: | |
149 | { | |
150 | #error "8" | |
151 | }; | |
152 | ]], | |
153 | [input.y:8: #error "8" | |
154 | ]) | |
155 | ||
156 | ||
157 | ## --------------------- ## | |
158 | ## Epilogue synch line. ## | |
159 | ## --------------------- ## | |
160 | ||
161 | AT_TEST_SYNCLINE([Epilogue synch line], | |
162 | [[%{ | |
163 | void yyerror (const char *s); | |
164 | int yylex (void); | |
165 | %} | |
166 | %% | |
167 | exp: '0'; | |
168 | %% | |
169 | #error "8" | |
170 | ]], | |
171 | [input.y:8: #error "8" | |
172 | ]) |