1 # Checking the Bison scanner. -*- Autotest -*-
3 # Copyright (C) 2002-2012 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
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.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 AT_BANNER([[Input Processing.]])
20 # Mostly test that we are robust to mistakes.
23 ## ---------------- ##
25 ## ---------------- ##
27 AT_SETUP([Invalid inputs])
39 AT_CHECK([[$PERL -pi -e 's/\\(\d{3})/chr(oct($1))/ge' input.y || exit 77]])
41 AT_BISON_CHECK([input.y], [1], [],
42 [[input.y:1.1-2: error: invalid characters: '\0\001\002\377?'
43 input.y:3.1: error: invalid character: '?'
44 input.y:4.14: error: invalid character: '}'
45 input.y:5.1: error: invalid character: '%'
46 input.y:5.2: error: invalid character: '&'
47 input.y:6.1-17: error: invalid directive: '%a-does-not-exist'
48 input.y:7.1: error: invalid character: '%'
49 input.y:7.2: error: invalid character: '-'
50 input.y:8.1-9.0: error: missing '%}' at end of file
51 input.y:8.1-9.0: error: syntax error, unexpected %{...%}
57 AT_SETUP([Invalid inputs with {}])
59 # We used to SEGV here. See
60 # http://lists.gnu.org/archive/html/bug-bison/2005-07/msg00053.html
72 AT_BISON_CHECK([input.y], [1], [],
73 [[input.y:3.1-15: error: syntax error, unexpected %initial-action, expecting {...}
84 AT_SETUP([Invalid $n and @n])
92 AT_BISON_CHECK([input.y], [1], [],
93 [[input.y:2.13-14: error: integer out of range: '$1'
94 input.y:3.13-14: error: integer out of range: '@1'
104 AT_SETUP([Type Clashes])
107 [[%union { int bar; }
111 exp: foo { $$; } foo { $2; } foo
117 AT_BISON_CHECK([input.y], [1], [],
118 [[input.y:5.12-13: error: $$ for the midrule at $2 of 'exp' has no declared type
119 input.y:5.24-25: error: $2 of 'exp' has no declared type
120 input.y:5.6-32: warning: type clash on default action: <bar> != <> [-Wother]
121 input.y:6.6-8: warning: type clash on default action: <bar> != <> [-Wother]
122 input.y:7.5: warning: empty rule for typed nonterminal, and no action [-Wother]
128 # _AT_UNUSED_VALUES_DECLARATIONS()
129 # --------------------------------
130 # Generate the token, type, and destructor
131 # declarations for the unused values tests.
132 m4_define([_AT_UNUSED_VALUES_DECLARATIONS],
133 [[[%token <integer> INT;
134 %type <integer> a b c d e f g h i j k l;
135 %destructor { destroy ($$); } INT a b c d e f g h i j k l;]]])
138 # AT_CHECK_UNUSED_VALUES(DECLARATIONS_AFTER, CHECK_MIDRULE_VALUES)
139 # ----------------------------------------------------------------
140 # Generate a grammar to test unused values, compile it, run it. If
141 # DECLARATIONS_AFTER is set, then the token, type, and destructor
142 # declarations are generated after the rules rather than before. If
143 # CHECK_MIDRULE_VALUES is set, then --warnings=midrule-values is set.
144 m4_define([AT_CHECK_UNUSED_VALUES],
149 ], [_AT_UNUSED_VALUES_DECLARATIONS
152 'a' a { $]2[; } | 'b' b { $]2[; } | 'c' c { $]2[; } | 'd' d { $]2[; }
153 | 'e' e { $]2[; } | 'f' f { $]2[; } | 'g' g { $]2[; } | 'h' h { $]2[; }
154 | 'i' i { $]2[; } | 'j' j { $]2[; } | 'k' k { $]2[; } | 'l' l { $]2[; }
157 a: INT | INT { } INT { } INT { };
158 b: INT | /* empty */;
159 c: INT | INT { $]1[; } INT { $<integer>2; } INT { $<integer>4; };
160 d: INT | INT { } INT { $]1[; } INT { $<integer>2; };
161 e: INT | INT { } INT { } INT { $]1[; };
162 f: INT | INT { } INT { } INT { $]$[ = $]1[ + $]3[ + $]5[; };
163 g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
164 h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
165 i: INT | INT INT { } { $]$[ = $]1[ + $]2[; };
166 j: INT | INT INT { $<integer>$ = 1; } { $]$[ = $]1[ + $]2[; };
167 k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
168 l: INT | INT { $<integer>$ = $<integer>1; } INT { $<integer>$ = $<integer>2 + $<integer>3; } INT { $<integer>$ = $<integer>4 + $<integer>5; };]]m4_ifval($1, [
169 _AT_UNUSED_VALUES_DECLARATIONS])
172 AT_BISON_CHECK(m4_ifval($2, [--warnings=midrule-values ])[-fcaret input.y],
174 [[input.y:11.10-32: warning: unset value: $][$ [-Wother]
175 a: INT | INT { } INT { } INT { };
176 ^^^^^^^^^^^^^^^^^^^^^^^
177 input.y:11.10-12: warning: unused value: $][1 [-Wother]
178 a: INT | INT { } INT { } INT { };
180 input.y:11.18-20: warning: unused value: $][3 [-Wother]
181 a: INT | INT { } INT { } INT { };
183 input.y:11.26-28: warning: unused value: $][5 [-Wother]
184 a: INT | INT { } INT { } INT { };
186 input.y:12.9: warning: empty rule for typed nonterminal, and no action [-Wother]
187 b: INT | /* empty */;
189 ]]m4_ifval($2, [[[input.y:13.14-20: warning: unset value: $][$ [-Wmidrule-values]
190 c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
192 input.y:13.26-41: warning: unset value: $][$ [-Wmidrule-values]
193 c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
195 ]]])[[input.y:13.10-62: warning: unset value: $][$ [-Wother]
196 c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
197 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
198 input.y:13.22-24: warning: unused value: $][3 [-Wother]
199 c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
201 input.y:13.43-45: warning: unused value: $][5 [-Wother]
202 c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
204 ]]m4_ifval($2, [[[input.y:14.14-16: warning: unset value: $][$ [-Wmidrule-values]
205 d: INT | INT { } INT { $][1; } INT { $<integer>2; };
207 ]]])[[input.y:14.10-49: warning: unset value: $][$ [-Wother]
208 d: INT | INT { } INT { $][1; } INT { $<integer>2; };
209 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
210 input.y:14.18-20: warning: unused value: $][3 [-Wother]
211 d: INT | INT { } INT { $][1; } INT { $<integer>2; };
213 input.y:14.30-32: warning: unused value: $][5 [-Wother]
214 d: INT | INT { } INT { $][1; } INT { $<integer>2; };
216 input.y:15.10-37: warning: unset value: $][$ [-Wother]
217 e: INT | INT { } INT { } INT { $][1; };
218 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
219 input.y:15.18-20: warning: unused value: $][3 [-Wother]
220 e: INT | INT { } INT { } INT { $][1; };
222 input.y:15.27-29: warning: unused value: $][5 [-Wother]
223 e: INT | INT { } INT { } INT { $][1; };
225 input.y:17.10-58: warning: unset value: $][$ [-Wother]
226 g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
227 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
228 input.y:17.10-12: warning: unused value: $][1 [-Wother]
229 g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
231 ]]m4_ifval($2, [[[input.y:17.14-29: warning: unused value: $][2 [-Wmidrule-values]
232 g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
234 ]]])[[input.y:17.31-33: warning: unused value: $][3 [-Wother]
235 g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
237 ]]m4_ifval($2, [[[input.y:17.35-50: warning: unused value: $][4 [-Wmidrule-values]
238 g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
240 ]]])[[input.y:17.52-54: warning: unused value: $][5 [-Wother]
241 g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
243 input.y:18.10-72: warning: unset value: $][$ [-Wother]
244 h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
245 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
246 input.y:18.10-12: warning: unused value: $][1 [-Wother]
247 h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
249 input.y:18.31-33: warning: unused value: $][3 [-Wother]
250 h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
252 ]]m4_ifval($2, [[[input.y:18.35-64: warning: unused value: $][4 [-Wmidrule-values]
253 h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
254 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
255 ]]])[[input.y:18.66-68: warning: unused value: $][5 [-Wother]
256 h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
258 ]]m4_ifval($2, [[[input.y:20.18-37: warning: unused value: $][3 [-Wmidrule-values]
259 j: INT | INT INT { $<integer>$ = 1; } { $][$ = $][1 + $][2; };
261 ]]])[[input.y:21.10-68: warning: unset value: $][$ [-Wother]
262 k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
263 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
264 input.y:21.10-12: warning: unused value: $][1 [-Wother]
265 k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
267 input.y:21.14-16: warning: unused value: $][2 [-Wother]
268 k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
270 ]]m4_ifval($2, [[[input.y:21.35-64: warning: unused value: $][4 [-Wmidrule-values]
271 k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
272 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
276 ## --------------- ##
278 ## --------------- ##
280 AT_SETUP([Unused values])
281 AT_CHECK_UNUSED_VALUES
282 AT_CHECK_UNUSED_VALUES(, [1])
286 ## ------------------------------------------ ##
287 ## Unused values before symbol declarations. ##
288 ## ------------------------------------------ ##
290 AT_SETUP([Unused values before symbol declarations])
291 AT_CHECK_UNUSED_VALUES([1])
292 AT_CHECK_UNUSED_VALUES([1], [1])
296 ## --------------------------------------------- ##
297 ## Default %printer and %destructor redeclared. ##
298 ## --------------------------------------------- ##
300 AT_SETUP([Default %printer and %destructor redeclared])
303 [[%destructor { destroy ($$); } <*> <*>
304 %printer { print ($$); } <*> <*>
306 %destructor { destroy ($$); } <*>
307 %printer { print ($$); } <*>
309 %destructor { destroy ($$); } <> <>
310 %printer { print ($$); } <> <>
312 %destructor { destroy ($$); } <>
313 %printer { print ($$); } <>
319 %destructor { destroy ($$); } <*>;
320 %printer { print ($$); } <*>;
322 %destructor { destroy ($$); } <>;
323 %printer { print ($$); } <>;
326 AT_BISON_CHECK([input.y], [1], [],
327 [[input.y:1.13-29: error: %destructor redeclaration for <*>
328 input.y:1.13-29: previous declaration
329 input.y:2.10-24: error: %printer redeclaration for <*>
330 input.y:2.10-24: previous declaration
331 input.y:4.13-29: error: %destructor redeclaration for <*>
332 input.y:1.13-29: previous declaration
333 input.y:5.10-24: error: %printer redeclaration for <*>
334 input.y:2.10-24: previous declaration
335 input.y:7.13-29: error: %destructor redeclaration for <>
336 input.y:7.13-29: previous declaration
337 input.y:8.10-24: error: %printer redeclaration for <>
338 input.y:8.10-24: previous declaration
339 input.y:10.13-29: error: %destructor redeclaration for <>
340 input.y:7.13-29: previous declaration
341 input.y:11.10-24: error: %printer redeclaration for <>
342 input.y:8.10-24: previous declaration
343 input.y:17.13-29: error: %destructor redeclaration for <*>
344 input.y:4.13-29: previous declaration
345 input.y:18.10-24: error: %printer redeclaration for <*>
346 input.y:5.10-24: previous declaration
347 input.y:20.13-29: error: %destructor redeclaration for <>
348 input.y:10.13-29: previous declaration
349 input.y:21.10-24: error: %printer redeclaration for <>
350 input.y:11.10-24: previous declaration
356 ## ---------------------------------------------- ##
357 ## Per-type %printer and %destructor redeclared. ##
358 ## ---------------------------------------------- ##
360 AT_SETUP([Per-type %printer and %destructor redeclared])
363 [[%destructor { destroy ($$); } <field1> <field2>
364 %printer { print ($$); } <field1> <field2>
366 %destructor { destroy ($$); } <field1> <field1>
367 %printer { print ($$); } <field2> <field2>
373 %destructor { destroy ($$); } <field2> <field1>;
374 %printer { print ($$); } <field2> <field1>;
377 AT_BISON_CHECK([input.y], [1], [],
378 [[input.y:4.13-29: error: %destructor redeclaration for <field1>
379 input.y:1.13-29: previous declaration
380 input.y:4.13-29: error: %destructor redeclaration for <field1>
381 input.y:4.13-29: previous declaration
382 input.y:5.10-24: error: %printer redeclaration for <field2>
383 input.y:2.10-24: previous declaration
384 input.y:5.10-24: error: %printer redeclaration for <field2>
385 input.y:5.10-24: previous declaration
386 input.y:11.13-29: error: %destructor redeclaration for <field1>
387 input.y:4.13-29: previous declaration
388 input.y:11.13-29: error: %destructor redeclaration for <field2>
389 input.y:1.13-29: previous declaration
390 input.y:12.10-24: error: %printer redeclaration for <field1>
391 input.y:2.10-24: previous declaration
392 input.y:12.10-24: error: %printer redeclaration for <field2>
393 input.y:5.10-24: previous declaration
398 ## ------------------- ##
399 ## Undefined symbols. ##
400 ## ------------------- ##
402 AT_SETUP([Undefined symbols])
405 [[%printer {} foo baz
412 AT_BISON_CHECK([input.y], [1], [],
413 [[input.y:2.16-18: error: symbol bar is used, but is not defined as a token and has no rules
414 input.y:1.17-19: warning: symbol baz is used, but is not defined as a token and has no rules [-Wother]
415 input.y:1.13-15: warning: symbol foo is used, but is not defined as a token and has no rules [-Wother]
416 input.y:3.13-15: warning: symbol qux is used, but is not defined as a token and has no rules [-Wother]
422 ## ----------------------------------------------------- ##
423 ## Unassociated types used for a printer or destructor. ##
424 ## ----------------------------------------------------- ##
426 AT_SETUP([Unassociated types used for a printer or destructor])
429 [[%token <type1> tag1
432 %printer { } <type1> <type3>
433 %destructor { } <type2> <type4>
443 AT_BISON_CHECK([input.y], [0], [],
444 [[input.y:4.22-28: warning: type <type3> is used, but is not associated to any symbol [-Wother]
445 input.y:5.25-31: warning: type <type4> is used, but is not associated to any symbol [-Wother]
451 ## --------------------------------- ##
452 ## Useless printers or destructors. ##
453 ## --------------------------------- ##
455 AT_SETUP([Useless printers or destructors])
457 # AT_TEST([INPUT], [STDERR])
458 # --------------------------
459 m4_pushdef([AT_TEST],
460 [AT_DATA([[input.y]],
463 AT_BISON_CHECK([input.y], [0], [], [$2
466 AT_TEST([[%token <type1> token1
467 %token <type2> token2
468 %token <type3> token3
469 %token <type4> token4
470 %token <type5> token51 token52
471 %token <type6> token61 token62
472 %token <type7> token7
475 %destructor {} token2
477 %destructor {} token61
482 %destructor {} <type2>
484 %destructor {} <type4>
487 %destructor {} <type6>
489 %destructor {} <type7>
493 [[input.y:16.13-19: warning: useless %printer for type <type1> [-Wother]
494 input.y:17.16-22: warning: useless %destructor for type <type2> [-Wother]]])
496 # If everybody is typed, <> is useless.
497 AT_TEST([[%type <type> exp
502 [[input.y:3.13-14: warning: useless %printer for type <> [-Wother]]])
504 # If nobody is typed, <*> is useless.
509 [[input.y:2.16-18: warning: useless %printer for type <*> [-Wother]]])
516 ## ---------------------------------------- ##
517 ## Unused values with default %destructor. ##
518 ## ---------------------------------------- ##
520 AT_SETUP([Unused values with default %destructor])
523 [[%destructor { destroy ($$); } <>
528 start: end end tagged tagged { $<tag>1; $3; } ;
533 AT_BISON_CHECK([input.y], [0], [],
534 [[input.y:6.8-45: warning: unset value: $$ [-Wother]
535 input.y:6.12-14: warning: unused value: $2 [-Wother]
536 input.y:7.6-8: warning: unset value: $$ [-Wother]
540 [[%destructor { destroy ($$); } <*>
545 start: end end tagged tagged { $<tag>1; $3; } ;
550 AT_BISON_CHECK([input.y], [0], [],
551 [[input.y:6.23-28: warning: unused value: $4 [-Wother]
552 input.y:8.9-11: warning: unset value: $$ [-Wother]
558 ## ----------------------------------------- ##
559 ## Unused values with per-type %destructor. ##
560 ## ----------------------------------------- ##
562 AT_SETUP([Unused values with per-type %destructor])
565 [[%destructor { destroy ($$); } <field1>
566 %type <field1> start end
570 start: end end { $1; } ;
574 AT_BISON_CHECK([input.y], [0], [],
575 [[input.y:6.8-22: warning: unset value: $$ [-Wother]
576 input.y:6.12-14: warning: unused value: $2 [-Wother]
577 input.y:7.6-8: warning: unset value: $$ [-Wother]
583 ## ---------------------- ##
584 ## Incompatible Aliases. ##
585 ## ---------------------- ##
587 AT_SETUP([Incompatible Aliases])
594 %destructor {bar} foo
599 %destructor {baz} "foo"
606 AT_BISON_CHECK([input.y], [1], [],
607 [[input.y:8.7-11: error: %type redeclaration for foo
608 input.y:3.7-11: previous declaration
609 input.y:10.13-17: error: %destructor redeclaration for foo
610 input.y:5.13-17: previous declaration
611 input.y:9.10-14: error: %printer redeclaration for foo
612 input.y:4.10-14: previous declaration
613 input.y:11.1-5: error: %left redeclaration for foo
614 input.y:6.1-5: previous declaration
621 ## ----------------------- ##
622 ## Torturing the Scanner. ##
623 ## ----------------------- ##
625 # Be sure to compile and run, so that the C compiler checks what
628 AT_SETUP([Torturing the Scanner])
630 AT_BISON_OPTION_PUSHDEFS
631 AT_DATA([input.y], [])
632 AT_BISON_CHECK([input.y], [1], [],
633 [[input.y:1.1: error: syntax error, unexpected end of file
640 AT_BISON_CHECK([input.y], [1], [],
641 [[input.y:1.1-2: error: syntax error, unexpected {...}
645 AT_DATA_GRAMMAR([input.y],
647 /* This is seen in GCC: a %{ and %} in middle of a comment. */
648 const char *foo = "So %{ and %} can be here too.";
651 /* These examples test Bison while not stressing C compilers too much.
652 Many C compilers mishandle backslash-newlines, so this part of the
653 test is inside "#if 0". The comment and string are written so that
654 the "#endif" will be seen regardless of the C compiler bugs that we
657 HP C (as of late 2002) mishandles *\[newline]\[newline]/ within a
660 The Apple Darwin compiler (as of late 2002) mishandles
661 \\[newline]' within a character constant.
666 * A comment with backslash-newlines in it. %} *\
669 /* { Close the above comment, if the C compiler mishandled it. */
672 " A string with backslash-newlines in it %{ %} \\
676 char apostrophe = '\'';
683 /* %{ and %} can be here too. */
686 /* Exercise pre-prologue dependency to %union. */
690 /* Exercise M4 quoting: '@:>@@:>@', 0. */
692 /* Also exercise %union. */
695 value ival; /* A comment to exercise an old bug. */
699 /* Exercise post-prologue dependency to %union. */
701 static YYSTYPE value_as_yystype (value val);
703 /* Exercise quotes in declarations. */
704 char quote[] = "@:>@@:>@,";
714 /* Exercise quotes in strings. */
715 %token FAKE "fake @<:@@:>@ \a\b\f\n\r\t\v\"\'\?\\\u005B\U0000005c ??!??'??(??)??-??/??<??=??> \x1\1"
718 /* Exercise M4 quoting: '@:>@@:>@', @<:@, 1. */
719 exp: '@<:@' '\1' two '$' '@' '{' oline output.or.oline.opt
721 /* Exercise quotes in braces. */
722 char tmp[] = "@<:@%c@:>@,\n";
727 two: '\x000000000000000000000000000000000000000000000000000000000000000000002';
728 oline: '@' 'o' 'l' 'i' 'n' 'e' '@' '_' '_' 'o' 'l' 'i' 'n' 'e' '_' '_';
729 output.or.oline.opt: ;|oline;;|output;;;
730 output: '#' 'o' 'u' 't' 'p' 'u' 't' ' ';
732 /* Exercise M4 quoting: '@:>@@:>@', @<:@, 2. */
735 value_as_yystype (value val)
745 static char const input[] = "@<:@\1\2$@{@oline@__@&t@oline__\
748 static size_t toknum;
749 assert (toknum < sizeof input);
750 yylval = value_as_yystype (input[toknum]);
751 return input[toknum++];
755 # Pacify Emacs'font-lock-mode: "
769 AT_BISON_OPTION_POPDEFS
771 AT_BISON_CHECK([-d -v -o input.c input.y])
772 AT_COMPILE([input.o])
774 AT_COMPILE([input], [input.o main.o])
775 AT_PARSER_CHECK([./input], 0,
782 ## ---------------------- ##
783 ## Typed symbol aliases. ##
784 ## ---------------------- ##
786 AT_SETUP([Typed symbol aliases])
788 # Bison 2.0 broke typed symbol aliases - ensure they work.
790 AT_DATA_GRAMMAR([input.y],
795 %token <val> MY_TOKEN "MY TOKEN"
802 AT_BISON_CHECK([-o input.c input.y])
811 m4_define([AT_CHECK_REQUIRE],
812 [AT_SETUP([Require $1])
813 AT_DATA_GRAMMAR([input.y],
818 AT_BISON_CHECK([-o input.c input.y], $2, [], ignore)
822 AT_CHECK_REQUIRE(1.0, 0)
823 AT_CHECK_REQUIRE(AT_PACKAGE_VERSION, 0)
824 ## FIXME: Some day augment this version number.
825 AT_CHECK_REQUIRE(100.0, 63)
828 ## ------------------------------------- ##
829 ## String aliases for character tokens. ##
830 ## ------------------------------------- ##
832 AT_SETUP([String aliases for character tokens])
834 # Bison once thought a character token and its alias were different
835 # symbols with the same user token number.
837 AT_DATA_GRAMMAR([input.y],
844 AT_BISON_CHECK([-o input.c input.y])
855 AT_BISON_OPTION_PUSHDEFS
856 AT_DATA_GRAMMAR([input.y],
858 %token WITHOUT_DASH "WITHOUT-DASH"
860 %token WITHOUT_PERIOD "WITHOUT.PERIOD"
866 start: with-dash without_dash with.period without_period;
867 with-dash: WITH-DASH;
868 without_dash: "WITHOUT-DASH";
869 with.period: WITH.PERIOD;
870 without_period: "WITHOUT.PERIOD";
875 AT_BISON_OPTION_POPDEFS
877 # POSIX Yacc accept periods, but not dashes.
878 AT_BISON_CHECK([--yacc -Wno-error input.y], [], [],
879 [[input.y:9.8-16: warning: POSIX Yacc forbids dashes in symbol names: WITH-DASH [-Wyacc]
880 input.y:18.8-16: warning: POSIX Yacc forbids dashes in symbol names: with-dash [-Wyacc]
883 # So warn about them.
884 AT_BISON_CHECK([-Wyacc input.y], [], [],
885 [[input.y:9.8-16: warning: POSIX Yacc forbids dashes in symbol names: WITH-DASH [-Wyacc]
886 input.y:18.8-16: warning: POSIX Yacc forbids dashes in symbol names: with-dash [-Wyacc]
889 # Dashes are fine for GNU Bison.
890 AT_BISON_CHECK([-o input.c input.y])
892 # Make sure we don't export silly token identifiers with periods or dashes.
893 AT_COMPILE([input.o])
896 # Periods are genuine letters, they can start identifiers.
897 # Digits and dashes cannot.
898 AT_DATA_GRAMMAR([input.y],
906 AT_BISON_CHECK([-o input.c input.y], [1], [],
907 [[input.y:10.10: error: invalid character: '-'
908 input.y:11.10-16: error: invalid identifier: '1NV4L1D'
909 input.y:12.10: error: invalid character: '-'
915 ## ----------------- ##
916 ## Numbered tokens. ##
917 ## ----------------- ##
919 AT_SETUP([Numbered tokens])
921 AT_DATA_GRAMMAR([redecl.y],
922 [[%token DECIMAL_1 11259375
923 HEXADECIMAL_1 0xabcdef
924 HEXADECIMAL_2 0xFEDCBA
927 start: DECIMAL_1 HEXADECIMAL_2;
930 AT_BISON_CHECK([redecl.y], [1], [],
931 [[redecl.y:10.10-22: error: user token number 11259375 redeclaration for HEXADECIMAL_1
932 redecl.y:9.8-16: previous declaration for DECIMAL_1
933 redecl.y:12.10-18: error: user token number 16702650 redeclaration for DECIMAL_2
934 redecl.y:11.10-22: previous declaration for HEXADECIMAL_2
937 AT_DATA_GRAMMAR([too-large.y],
938 [[%token TOO_LARGE_DEC 999999999999999999999
939 TOO_LARGE_HEX 0xFFFFFFFFFFFFFFFFFFF
941 start: TOO_LARGE_DEC TOO_LARGE_HEX
945 AT_BISON_CHECK([too-large.y], [1], [],
946 [[too-large.y:9.22-42: error: integer out of range: '999999999999999999999'
947 too-large.y:10.24-44: error: integer out of range: '0xFFFFFFFFFFFFFFFFFFF'
953 ## --------------------- ##
954 ## Unclosed constructs. ##
955 ## --------------------- ##
957 AT_SETUP([Unclosed constructs])
959 # Bison's scan-gram.l once forgot to STRING_FINISH some unclosed
960 # constructs, so they were prepended to whatever it STRING_GROW'ed
961 # next. It also threw them away rather than returning them to the
962 # parser. The effect was confusing subsequent error messages.
967 %token AB "ab" // Used to complain that "ab" was already used.
970 %token TICK_TWELVE "'12" // Used to complain that "'12" was already used.
976 // Used to report a syntax error because it didn't see any kind of symbol
982 // Used to report a syntax error because it didn't see braced code.
983 %destructor { free ($$)
986 AT_BISON_CHECK([-o input.c input.y], 1, [],
987 [[input.y:1.10-2.0: error: missing '"' at end of line
988 input.y:4.10-5.0: error: missing "'" at end of line
989 input.y:14.11-15.0: error: missing "'" at end of line
990 input.y:16.11-17.0: error: missing '"' at end of line
991 input.y:19.13-20.0: error: missing '}' at end of file
992 input.y:20.1: error: syntax error, unexpected end of file
995 AT_BISON_CHECK([-fcaret -o input.c input.y], 1, [],
996 [[input.y:1.10-2.0: error: missing '"' at end of line
999 input.y:4.10-5.0: error: missing "'" at end of line
1002 input.y:14.11-15.0: error: missing "'" at end of line
1005 input.y:16.11-17.0: error: missing '"' at end of line
1008 input.y:19.13-20.0: error: missing '}' at end of file
1009 %destructor { free ($$)
1011 input.y:20.1: error: syntax error, unexpected end of file
1017 ## ------------------------- ##
1018 ## %start after first rule. ##
1019 ## ------------------------- ##
1021 AT_SETUP([%start after first rule])
1023 # Bison once complained that a %start after the first rule was a
1024 # redeclaration of the start symbol.
1029 start: false_start ;
1033 AT_BISON_CHECK([-o input.c input.y])
1038 ## --------------------- ##
1039 ## %prec takes a token. ##
1040 ## --------------------- ##
1042 AT_SETUP([%prec takes a token])
1044 # Bison once allowed %prec sym where sym was a nonterminal.
1048 start: PREC %prec PREC ;
1052 AT_BISON_CHECK([input.y], [1], [],
1053 [[input.y:3.1-4: error: rule given for PREC, which is a token
1059 ## ------------------------------- ##
1060 ## %prec's token must be defined. ##
1061 ## ------------------------------- ##
1063 AT_SETUP([[%prec's token must be defined]])
1065 # According to POSIX, a %prec token must be defined separately.
1067 AT_DATA([[input.y]],
1072 AT_BISON_CHECK([[input.y]], [[0]], [],
1073 [[input.y:2.8-17: warning: token for %prec is not defined: PREC [-Wother]
1079 ## -------------------------------- ##
1080 ## Reject unused %code qualifiers. ##
1081 ## -------------------------------- ##
1083 AT_SETUP([Reject unused %code qualifiers])
1085 AT_DATA([input-c.y],
1093 AT_BISON_CHECK([[input-c.y]], [[1]], [],
1094 [[input-c.y:1.7: error: %code qualifier 'q' is not used
1095 input-c.y:2.7-9: error: %code qualifier 'bad' is not used
1096 input-c.y:3.7-9: error: %code qualifier 'bad' is not used
1097 input-c.y:4.7-12: error: %code qualifier 'format' is not used
1100 AT_DATA([input-c-glr.y],
1107 AT_BISON_CHECK([[input-c-glr.y]], [[1]], [],
1108 [[input-c-glr.y:1.7: error: %code qualifier 'q' is not used
1109 input-c-glr.y:2.7-9: error: %code qualifier 'bad' is not used
1110 input-c-glr.y:3.8-10: error: %code qualifier 'bad' is not used
1113 AT_DATA([input-c++.y],
1120 AT_BISON_CHECK([[input-c++.y]], [[1]], [],
1121 [[input-c++.y:1.7: error: %code qualifier 'q' is not used
1122 input-c++.y:2.7-9: error: %code qualifier 'bad' is not used
1123 input-c++.y:3.8: error: %code qualifier 'q' is not used
1126 AT_DATA([input-c++-glr.y],
1133 AT_BISON_CHECK([[input-c++-glr.y]], [[1]], [],
1134 [[input-c++-glr.y:1.7-9: error: %code qualifier 'bad' is not used
1135 input-c++-glr.y:2.7: error: %code qualifier 'q' is not used
1136 input-c++-glr.y:3.7: error: %code qualifier 'q' is not used
1139 AT_DATA([special-char-@@.y],
1146 AT_BISON_CHECK([[special-char-@@.y]], [[1]], [],
1147 [[special-char-@@.y:1.7-9: error: %code qualifier 'bad' is not used
1148 special-char-@@.y:2.7: error: %code qualifier 'q' is not used
1149 special-char-@@.y:3.7: error: %code qualifier 'q' is not used
1152 AT_DATA([special-char-@:>@.y],
1159 AT_BISON_CHECK([[special-char-@:>@.y]], [[1]], [],
1160 [[special-char-@:>@.y:1.7-9: error: %code qualifier 'bad' is not used
1161 special-char-@:>@.y:2.7: error: %code qualifier 'q' is not used
1162 special-char-@:>@.y:3.7: error: %code qualifier 'q' is not used
1168 ## ---------------- ##
1169 ## %define errors. ##
1170 ## ---------------- ##
1172 AT_SETUP([%define errors])
1174 AT_DATA([input-redefined.y],
1175 [[%define var "value1"
1176 %define var "value1"
1177 %define var "value2"
1178 %define special1 "@:>@"
1179 %define special2 "@<:@"
1184 AT_BISON_CHECK([[input-redefined.y]], [[1]], [],
1185 [[input-redefined.y:2.9-11: error: %define variable 'var' redefined
1186 input-redefined.y:1.9-11: previous definition
1187 input-redefined.y:3.10-12: error: %define variable 'var' redefined
1188 input-redefined.y:2.9-11: previous definition
1191 AT_DATA([input-unused.y],
1192 [[%define var "value"
1197 AT_BISON_CHECK([[input-unused.y]], [[1]], [],
1198 [[input-unused.y:1.9-11: error: %define variable 'var' is not used
1204 ## ----------------------------------- ##
1205 ## %define, --define, --force-define. ##
1206 ## ----------------------------------- ##
1208 AT_SETUP([[%define, --define, --force-define]])
1211 [[m4@&t@_divert_push(0)@
1212 @output(b4_parser_file_name@)@
1213 [var-dd: ]b4_percent_define_get([[var-dd]])[
1214 var-ff: ]b4_percent_define_get([[var-ff]])[
1215 var-dfg: ]b4_percent_define_get([[var-dfg]])[
1216 var-fd: ]b4_percent_define_get([[var-fd]])
1217 m4@&t@_divert_pop(0)
1219 AT_DATA([[input.y]],
1220 [[%define var-dfg "gram"
1224 AT_BISON_CHECK([[-Dvar-dd=cmd-d1 -Dvar-dd=cmd-d2 \
1225 -Fvar-ff=cmd-f1 -Fvar-ff=cmd-f2 \
1226 -Dvar-dfg=cmd-d -Fvar-dfg=cmd-f \
1227 -Fvar-fd=cmd-f -Dvar-fd=cmd-d \
1228 --skeleton ./skel.c input.y]])
1229 AT_CHECK([[cat input.tab.c]], [[0]],
1236 AT_DATA([[input-dg.y]],
1237 [[%define var "gram"
1241 AT_BISON_CHECK([[-Dvar=cmd-d input-dg.y]], [[1]], [],
1242 [[input-dg.y:1.9-11: error: %define variable 'var' redefined
1243 <command line>:1: previous definition
1246 AT_DATA([[input-dg.y]],
1247 [[%define var "gram"
1251 AT_BISON_CHECK([[-fcaret -Dvar=cmd-d input-dg.y]], [[1]], [],
1252 [[input-dg.y:1.9-11: error: %define variable 'var' redefined
1255 <command line>:2: previous definition
1258 AT_DATA([[input-unused.y]],
1262 AT_BISON_CHECK([[-Dunused-d -Funused-f input-unused.y]], [[1]], [],
1263 [[<command line>:1: error: %define variable 'unused-d' is not used
1264 <command line>:2: error: %define variable 'unused-f' is not used
1269 ## --------------------------- ##
1270 ## %define Boolean variables. ##
1271 ## --------------------------- ##
1273 AT_SETUP([["%define" Boolean variables]])
1277 %define public "maybe"
1278 %define parser_class_name "Input"
1283 AT_BISON_CHECK([[Input.y]], [1], [],
1284 [[Input.y:2.9-14: error: invalid value for %define Boolean variable 'public'
1289 ## ------------------------ ##
1290 ## %define enum variables. ##
1291 ## ------------------------ ##
1293 AT_SETUP([["%define" enum variables]])
1295 # Check errors from the front-end, and the back-end. Since the
1296 # front-end quits before calling the back-end, these tests cannot be
1300 AT_DATA([[input.y]],
1301 [[%define lr.default-reduction bogus
1305 AT_BISON_CHECK([[-fcaret input.y]], [[1]], [[]],
1306 [[input.y:1.9-28: error: invalid value for %define variable 'lr.default-reduction': 'bogus'
1307 %define lr.default-reduction bogus
1308 ^^^^^^^^^^^^^^^^^^^^
1309 input.y:1.9-28: accepted value: 'most'
1310 input.y:1.9-28: accepted value: 'consistent'
1311 input.y:1.9-28: accepted value: 'accepting'
1315 AT_DATA([[input.y]],
1316 [[%define api.push-pull neither
1320 AT_BISON_CHECK([[-fcaret input.y]], [[1]], [[]],
1321 [[input.y:1.9-21: error: invalid value for %define variable 'api.push-pull': 'neither'
1322 %define api.push-pull neither
1324 input.y:1.9-21: accepted value: 'pull'
1325 input.y:1.9-21: accepted value: 'push'
1326 input.y:1.9-21: accepted value: 'both'
1331 ## -------------------------------- ##
1332 ## %define backward compatibility. ##
1333 ## -------------------------------- ##
1335 AT_SETUP([["%define" backward compatibility]])
1337 # The error messages tell us whether the variables are properly updated.
1338 AT_DATA([[input.y]],
1339 [[%define api.push_pull both
1340 %define lr.keep_unreachable_states maybe
1341 %define namespace "foo"
1342 %define api.namespace "foo"
1347 AT_BISON_CHECK([[-fcaret input.y]], [1], [],
1348 [[input.y:1.9-21: warning: deprecated directive, use '%define api.push-pull both' [-Wdeprecated]
1349 %define api.push_pull both
1351 input.y:2.9-34: warning: deprecated directive, use '%define lr.keep-unreachable-state maybe' [-Wdeprecated]
1352 %define lr.keep_unreachable_states maybe
1353 ^^^^^^^^^^^^^^^^^^^^^^^^^^
1354 input.y:3.9-17: warning: deprecated directive, use '%define api.namespace foo' [-Wdeprecated]
1355 %define namespace "foo"
1357 input.y:4.9-21: error: %define variable 'api.namespace' redefined
1358 %define api.namespace "foo"
1360 input.y:3.9-17: previous definition
1361 %define namespace "foo"
1363 input.y:5.9-15: warning: deprecated directive, use '%define api.value.type variant' [-Wdeprecated]
1370 ## ------------------------- ##
1371 ## Unused %define api.pure. ##
1372 ## ------------------------- ##
1374 AT_SETUP([[Unused %define api.pure]])
1376 # AT_CHECK_API_PURE(DECLS, VALUE)
1377 # -------------------------------
1378 # Make sure Bison reports that `%define api.pure VALUE' is unused when DECLS
1380 m4_define([AT_CHECK_API_PURE],
1382 AT_DATA([[input.y]],
1383 [[%define api.pure ]$2[
1389 AT_BISON_CHECK([[input.y]], [[1]], [],
1390 [[input.y:1.9-16: error: %define variable 'api.pure' is not used
1394 AT_CHECK_API_PURE([[%language "c++" %defines]], [[]])
1395 AT_CHECK_API_PURE([[%language "c++" %defines]], [[false]])
1396 AT_CHECK_API_PURE([[%language "c++" %defines %glr-parser]], [[""]])
1397 AT_CHECK_API_PURE([[%language "c++" %defines %glr-parser]], [[false]])
1398 AT_CHECK_API_PURE([[%language "java"]], [[true]])
1399 AT_CHECK_API_PURE([[%language "java"]], [[false]])
1403 ## -------------------------------- ##
1404 ## C++ namespace reference errors. ##
1405 ## -------------------------------- ##
1407 AT_SETUP([[C++ namespace reference errors]])
1409 # AT_CHECK_NAMESPACE_ERROR(NAMESPACE-DECL, ERROR, [ERROR], ...)
1410 # -------------------------------------------------------------
1411 # Make sure Bison reports all ERROR's for %define namespace "NAMESPACE-DECL".
1412 m4_define([AT_CHECK_NAMESPACE_ERROR],
1414 AT_DATA([[input.y]],
1417 %define api.namespace "]$1["
1422 AT_BISON_CHECK([[input.y]], [1], [],
1423 [m4_foreach([b4_arg], m4_dquote(m4_shift($@)),
1424 [[input.y:3.9-21: error: ]b4_arg[
1428 AT_CHECK_NAMESPACE_ERROR([[]],
1429 [[namespace reference is empty]])
1430 AT_CHECK_NAMESPACE_ERROR([[ ]],
1431 [[namespace reference is empty]])
1432 AT_CHECK_NAMESPACE_ERROR([[foo::::bar]],
1433 [[namespace reference has consecutive "::"]])
1434 AT_CHECK_NAMESPACE_ERROR([[foo:: ::bar]],
1435 [[namespace reference has consecutive "::"]])
1436 AT_CHECK_NAMESPACE_ERROR([[::::bar]],
1437 [[namespace reference has consecutive "::"]])
1438 AT_CHECK_NAMESPACE_ERROR([[:: ::bar]],
1439 [[namespace reference has consecutive "::"]])
1440 AT_CHECK_NAMESPACE_ERROR([[foo::bar:: ::]],
1441 [[namespace reference has consecutive "::"]],
1442 [[namespace reference has a trailing "::"]])
1443 AT_CHECK_NAMESPACE_ERROR([[foo::bar::]],
1444 [[namespace reference has a trailing "::"]])
1445 AT_CHECK_NAMESPACE_ERROR([[foo::bar:: ]],
1446 [[namespace reference has a trailing "::"]])
1447 AT_CHECK_NAMESPACE_ERROR([[::]],
1448 [[namespace reference has a trailing "::"]])
1452 ## ------------------------ ##
1453 ## Bad character literals. ##
1454 ## ------------------------ ##
1456 # Bison used to accept character literals that were empty or contained
1457 # too many characters.
1459 # FIXME: AT_DATA or some variant of AT_DATA may eventually permit
1460 # the final newline to be omitted. See the threads starting at
1461 # <http://lists.gnu.org/archive/html/bison-patches/2009-07/msg00019.html>.
1463 AT_SETUP([[Bad character literals]])
1470 AT_CHECK([[$PERL -e "print 'start: \'';" >> empty.y || exit 77]])
1472 AT_BISON_CHECK([empty.y], [1], [],
1473 [[empty.y:2.8-9: warning: empty character literal [-Wother]
1474 empty.y:3.8-4.0: warning: empty character literal [-Wother]
1475 empty.y:3.8-4.0: error: missing "'" at end of line
1476 empty.y:4.8: warning: empty character literal [-Wother]
1477 empty.y:4.8: error: missing "'" at end of file
1485 AT_CHECK([[$PERL -e "print 'start: \'ab';" >> two.y || exit 77]])
1487 AT_BISON_CHECK([two.y], [1], [],
1488 [[two.y:2.8-11: warning: extra characters in character literal [-Wother]
1489 two.y:3.8-4.0: warning: extra characters in character literal [-Wother]
1490 two.y:3.8-4.0: error: missing "'" at end of line
1491 two.y:4.8-10: warning: extra characters in character literal [-Wother]
1492 two.y:4.8-10: error: missing "'" at end of file
1500 AT_CHECK([[$PERL -e "print 'start: \'abc';" >> three.y || exit 77]])
1502 AT_BISON_CHECK([three.y], [1], [],
1503 [[three.y:2.8-12: warning: extra characters in character literal [-Wother]
1504 three.y:3.8-4.0: warning: extra characters in character literal [-Wother]
1505 three.y:3.8-4.0: error: missing "'" at end of line
1506 three.y:4.8-11: warning: extra characters in character literal [-Wother]
1507 three.y:4.8-11: error: missing "'" at end of file
1512 ## ------------------------- ##
1513 ## Bad escapes in literals. ##
1514 ## ------------------------- ##
1516 AT_SETUP([[Bad escapes in literals]])
1520 start: '\777' '\0' '\xfff' '\x0'
1521 '\uffff' '\u0000' '\Uffffffff' '\U00000000'
1525 # It is not easy to create special characters, we cannot even trust tr.
1526 # Beside we cannot even expect "echo '\0'" to output two characters
1527 # (well three with \n): at least Bash 3.2 converts the two-character
1528 # sequence "\0" into a single NUL character.
1529 AT_CHECK([[$PERL -e 'print "start: \"\\\t\\\f\\\0\\\1\" ;";' >> input.y \
1532 AT_BISON_CHECK([input.y], [1], [],
1533 [[input.y:2.9-12: error: invalid number after \-escape: 777
1534 input.y:2.8-13: warning: empty character literal [-Wother]
1535 input.y:2.16-17: error: invalid number after \-escape: 0
1536 input.y:2.15-18: warning: empty character literal [-Wother]
1537 input.y:2.21-25: error: invalid number after \-escape: xfff
1538 input.y:2.20-26: warning: empty character literal [-Wother]
1539 input.y:2.29-31: error: invalid number after \-escape: x0
1540 input.y:2.28-32: warning: empty character literal [-Wother]
1541 input.y:3.9-14: error: invalid number after \-escape: uffff
1542 input.y:3.8-15: warning: empty character literal [-Wother]
1543 input.y:3.18-23: error: invalid number after \-escape: u0000
1544 input.y:3.17-24: warning: empty character literal [-Wother]
1545 input.y:3.27-36: error: invalid number after \-escape: Uffffffff
1546 input.y:3.26-37: warning: empty character literal [-Wother]
1547 input.y:3.40-49: error: invalid number after \-escape: U00000000
1548 input.y:3.39-50: warning: empty character literal [-Wother]
1549 input.y:4.9-10: error: invalid character after \-escape: ' '
1550 input.y:4.8-11: warning: empty character literal [-Wother]
1551 input.y:4.14-15: error: invalid character after \-escape: A
1552 input.y:4.13-16: warning: empty character literal [-Wother]
1553 input.y:5.9-16: error: invalid character after \-escape: \t
1554 input.y:5.17: error: invalid character after \-escape: \f
1555 input.y:5.18: error: invalid character after \-escape: \0
1556 input.y:5.19: error: invalid character after \-escape: \001
1561 ## ------------------------- ##
1562 ## LAC: Errors for %define. ##
1563 ## ------------------------- ##
1565 AT_SETUP([[LAC: Errors for %define]])
1567 AT_DATA([[input.y]],
1572 # parse.lac.* options are useless if LAC isn't actually activated.
1573 AT_BISON_CHECK([[-Dparse.lac.es-capacity-initial=1 input.y]],
1575 [[<command line>:1: error: %define variable 'parse.lac.es-capacity-initial' is not used
1577 AT_BISON_CHECK([[-Dparse.lac.memory-trace=full input.y]],
1579 [[<command line>:1: error: %define variable 'parse.lac.memory-trace' is not used
1584 ## --------------------------------------------- ##
1585 ## -Werror is not affected by -Wnone and -Wall. ##
1586 ## --------------------------------------------- ##
1588 AT_SETUP([[-Werror is not affected by -Wnone and -Wall]])
1590 AT_DATA([[input.y]],
1595 # -Werror is not enabled by -Wall or equivalent.
1596 AT_BISON_CHECK([[-Wall input.y]], [[0]], [[]],
1597 [[input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar [-Wyacc]
1599 AT_BISON_CHECK([[-W input.y]], [[0]], [[]],
1600 [[input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar [-Wyacc]
1602 AT_BISON_CHECK([[-Wno-none input.y]], [[0]], [[]],
1603 [[input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar [-Wyacc]
1606 # -Werror is not disabled by -Wnone or equivalent.
1607 AT_BISON_CHECK([[-Werror,none,yacc input.y]], [[1]], [[]], [[stderr]])
1608 AT_CHECK([[sed 's/^.*bison:/bison:/' stderr]], [[0]],
1609 [[input.y:2.1-7: error: POSIX Yacc forbids dashes in symbol names: foo-bar [-Werror=yacc]
1612 AT_BISON_CHECK([[-Werror,no-all,yacc input.y]], [[1]], [[]], [[experr]])
1617 ## ------------------------------------------------------ ##
1618 ## %name-prefix and %define api.prefix are incompatible. ##
1619 ## ------------------------------------------------------ ##
1621 AT_SETUP([[%name-prefix and api.prefix are incompatible]])
1623 # AT_TEST(DIRECTIVES, OPTIONS, ERROR-LOCATION)
1624 # --------------------------------------------
1625 m4_pushdef([AT_TEST],
1626 [AT_DATA([[input.y]],
1631 AT_BISON_CHECK([[$2 input.y]], [[1]], [[]],
1632 [[$3: error: '%name-prefix' and '%define api.prefix' cannot be used together
1636 AT_TEST([%define api.prefix foo %name-prefix "bar"], [], [input.y:1.9-18])
1637 AT_TEST([], [-Dapi.prefix=foo -p bar], [<command line>:1])
1638 AT_TEST([%name-prefix "bar"], [-Dapi.prefix=foo], [<command line>:1])
1639 AT_TEST([%define api.prefix foo], [-p bar], [input.y:1.9-18])
1641 m4_popdef([AT_TEST])
1646 ## -------------- ##
1648 ## -------------- ##
1650 AT_SETUP([[Stray $ or @]])
1652 # Give %printer and %destructor "<*> exp TOK" instead of "<*>" to
1653 # check that the warnings are reported once, not three times.
1655 AT_DATA_GRAMMAR([[input.y]],
1657 %token <TYPE> TOK TOK2
1658 %destructor { $%; @%; } <*> exp TOK;
1659 %initial-action { $%; @%; };
1660 %printer { $%; @%; } <*> exp TOK;
1662 exp: TOK { $%; @%; $$ = $1; };
1665 AT_BISON_CHECK([[input.y]], 0, [],
1666 [[input.y:11.19: warning: stray '$' [-Wother]
1667 input.y:11.23: warning: stray '@' [-Wother]
1668 input.y:12.19: warning: stray '$' [-Wother]
1669 input.y:12.23: warning: stray '@' [-Wother]
1670 input.y:13.19: warning: stray '$' [-Wother]
1671 input.y:13.23: warning: stray '@' [-Wother]
1672 input.y:15.19: warning: stray '$' [-Wother]
1673 input.y:15.23: warning: stray '@' [-Wother]
1680 ## ---------------- ##
1681 ## Code injection. ##
1682 ## ---------------- ##
1685 AT_SETUP([[Code injection]])
1687 m4_pattern_allow([^m4_errprintn$])
1691 # Try to have MACRO be run by bison.
1692 m4_pushdef([AT_TEST],
1693 [AT_DATA([[input.y]],
1694 [[%type <$1(DEAD %type)> exp
1695 %token <$1(DEAD %token)> a
1700 $<$1(DEAD %initial-action)>$
1705 $<$1(DEAD %printer)>$
1713 $1(DEAD %parse-param)
1721 $<$1(DEAD action 1)>$
1722 $<$1(DEAD action 2)>1
1723 $<$1(DEAD action 3)>name
1724 $<$1(DEAD action 4)>0
1729 # FIXME: Provide a means to iterate over all the skeletons.
1730 AT_BISON_CHECK([[-d input.y]])
1731 AT_BISON_CHECK([[-d -S glr.c input.y]])
1732 AT_BISON_CHECK([[-d -S lalr1.cc input.y]])
1733 AT_BISON_CHECK([[-d -S glr.cc input.y]])
1734 AT_BISON_CHECK([[ -S lalr1.java input.y]])
1737 AT_TEST([m4_errprintn])
1738 AT_TEST([@:>@m4_errprintn])
1740 m4_popdef([AT_TEST])
1744 ##----------------------- ##
1745 ## Deprecated directives. ##
1746 ## ---------------------- ##
1748 AT_SETUP([[Deprecated directives]])
1750 AT_KEYWORDS([[deprec]])
1752 AT_DATA_GRAMMAR([[input.y]],
1757 %file-prefix = "foo"
1775 AT_BISON_CHECK([[input.y]], [[0]], [[]],
1776 [[input.y:10.1-13: warning: deprecated directive: '%default_prec', use '%default-prec' [-Wdeprecated]
1777 input.y:11.1-14: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
1778 input.y:12.1-10: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
1779 input.y:13.1-14: warning: deprecated directive: '%file-prefix =', use '%file-prefix' [-Wdeprecated]
1780 input.y:14.1-15.2: warning: deprecated directive: '%file-prefix\n =', use '%file-prefix' [-Wdeprecated]
1781 input.y:17.1-19: warning: deprecated directive: '%fixed-output_files', use '%fixed-output-files' [-Wdeprecated]
1782 input.y:18.1-19: warning: deprecated directive: '%fixed_output-files', use '%fixed-output-files' [-Wdeprecated]
1783 input.y:20.1-13: warning: deprecated directive: '%name-prefix=', use '%name-prefix' [-Wdeprecated]
1784 input.y:21.1-16: warning: deprecated directive: '%no-default_prec', use '%no-default-prec' [-Wdeprecated]
1785 input.y:22.1-16: warning: deprecated directive: '%no_default-prec', use '%no-default-prec' [-Wdeprecated]
1786 input.y:23.1-9: warning: deprecated directive: '%no_lines', use '%no-lines' [-Wdeprecated]
1787 input.y:24.1-9: warning: deprecated directive: '%output =', use '%output' [-Wdeprecated]
1788 input.y:25.1-12: warning: deprecated directive: '%pure_parser', use '%pure-parser' [-Wdeprecated]
1789 input.y:26.1-12: warning: deprecated directive: '%token_table', use '%token-table' [-Wdeprecated]
1794 ## ---------------------------- ##
1795 ## Unput's effect on locations. ##
1796 ## ---------------------------- ##
1797 dnl When the scanner detects a deprecated construct, it unputs the correct
1798 dnl version, but it should *not* have any impact on the scanner cursor. If it
1799 dnl does, the locations of directives on the same line become erroneous.
1801 AT_SETUP([[Unput's effect on locations]])
1803 AT_KEYWORDS([[deprec]])
1805 AT_DATA_GRAMMAR([[input.y]],
1808 %expect_rr 42 %expect_rr 42
1810 %error_verbose %error_verbose
1815 AT_BISON_CHECK([[input.y]], [[1]], [[]],
1816 [[input.y:11.1-10: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
1817 input.y:11.15-24: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
1818 input.y:12.15-24: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
1819 input.y:13.1-14: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
1820 input.y:13.16-29: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
1821 input.y:13.11-21: error: %define variable 'parse.error' redefined
1822 input.y:13-6: previous definition
1823 input.y:14.16-29: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
1824 input.y:14.11-21: error: %define variable 'parse.error' redefined
1825 input.y:13.11-21: previous definition
1830 ##--------------------------- ##
1831 ## Non-deprecated directives. ##
1832 ## -------------------------- ##
1834 AT_SETUP([[Non-deprecated directives]])
1836 AT_KEYWORDS([[deprec]])
1838 AT_DATA_GRAMMAR([[input.y]],
1856 AT_BISON_CHECK([[input.y]], [[0]], [[]],
1857 [[input.y: warning: %expect-rr applies only to GLR parsers [-Wother]