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