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: error: invalid character: '\0'
43 input.y:1.1: error: invalid character: '\001'
44 input.y:1.1: error: invalid character: '\002'
45 input.y:1.1: error: invalid character: '\377'
46 input.y:1.2: error: invalid character: '?'
47 input.y:3.1: error: invalid character: '?'
48 input.y:4.14: error: invalid character: '}'
49 input.y:5.1: error: invalid character: '%'
50 input.y:5.2: error: invalid character: '&'
51 input.y:6.1-17: error: invalid directive: '%a-does-not-exist'
52 input.y:7.1: error: invalid character: '%'
53 input.y:7.2: error: invalid character: '-'
54 input.y:8.1-9.0: error: missing '%}' at end of file
55 input.y:8.1-9.0: error: syntax error, unexpected %{...%}
61 AT_SETUP([Invalid inputs with {}])
63 # We used to SEGV here. See
64 # http://lists.gnu.org/archive/html/bug-bison/2005-07/msg00053.html
76 AT_BISON_CHECK([input.y], [1], [],
77 [[input.y:3.1-15: error: syntax error, unexpected %initial-action, expecting {...}
88 AT_SETUP([Invalid $n and @n])
96 AT_BISON_CHECK([input.y], [1], [],
97 [[input.y:2.13-14: error: integer out of range: '$1'
98 input.y:3.13-14: error: integer out of range: '@1'
108 AT_SETUP([Type Clashes])
111 [[%union { int bar; }
115 exp: foo { $$; } foo { $2; } foo
121 AT_BISON_CHECK([input.y], [1], [],
122 [[input.y:5.12-13: error: $$ for the midrule at $2 of 'exp' has no declared type
123 input.y:5.24-25: error: $2 of 'exp' has no declared type
124 input.y:5.6-32: warning: type clash on default action: <bar> != <> [-Wother]
125 input.y:6.6-8: warning: type clash on default action: <bar> != <> [-Wother]
126 input.y:7.5: warning: empty rule for typed nonterminal, and no action [-Wother]
132 # _AT_UNUSED_VALUES_DECLARATIONS()
133 # --------------------------------
134 # Generate the token, type, and destructor
135 # declarations for the unused values tests.
136 m4_define([_AT_UNUSED_VALUES_DECLARATIONS],
137 [[[%token <integer> INT;
138 %type <integer> a b c d e f g h i j k l;
139 %destructor { destroy ($$); } INT a b c d e f g h i j k l;]]])
142 # AT_CHECK_UNUSED_VALUES(DECLARATIONS_AFTER, CHECK_MIDRULE_VALUES)
143 # ----------------------------------------------------------------
144 # Generate a grammar to test unused values, compile it, run it. If
145 # DECLARATIONS_AFTER is set, then the token, type, and destructor
146 # declarations are generated after the rules rather than before. If
147 # CHECK_MIDRULE_VALUES is set, then --warnings=midrule-values is set.
148 m4_define([AT_CHECK_UNUSED_VALUES],
153 ], [_AT_UNUSED_VALUES_DECLARATIONS
156 'a' a { $]2[; } | 'b' b { $]2[; } | 'c' c { $]2[; } | 'd' d { $]2[; }
157 | 'e' e { $]2[; } | 'f' f { $]2[; } | 'g' g { $]2[; } | 'h' h { $]2[; }
158 | 'i' i { $]2[; } | 'j' j { $]2[; } | 'k' k { $]2[; } | 'l' l { $]2[; }
161 a: INT | INT { } INT { } INT { };
162 b: INT | /* empty */;
163 c: INT | INT { $]1[; } INT { $<integer>2; } INT { $<integer>4; };
164 d: INT | INT { } INT { $]1[; } INT { $<integer>2; };
165 e: INT | INT { } INT { } INT { $]1[; };
166 f: INT | INT { } INT { } INT { $]$[ = $]1[ + $]3[ + $]5[; };
167 g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
168 h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
169 i: INT | INT INT { } { $]$[ = $]1[ + $]2[; };
170 j: INT | INT INT { $<integer>$ = 1; } { $]$[ = $]1[ + $]2[; };
171 k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
172 l: INT | INT { $<integer>$ = $<integer>1; } INT { $<integer>$ = $<integer>2 + $<integer>3; } INT { $<integer>$ = $<integer>4 + $<integer>5; };]]m4_ifval($1, [
173 _AT_UNUSED_VALUES_DECLARATIONS])
176 AT_BISON_CHECK(m4_ifval($2, [ --warnings=midrule-values ])[ input.y], [0], [],
177 [[input.y:11.10-32: warning: unset value: $]$[ [-Wother]
178 input.y:11.10-32: warning: unused value: $]1[ [-Wother]
179 input.y:11.10-32: warning: unused value: $]3[ [-Wother]
180 input.y:11.10-32: warning: unused value: $]5[ [-Wother]
181 input.y:12.9: warning: empty rule for typed nonterminal, and no action [-Wother]
182 ]]m4_ifval($2, [[[input.y:13.14-20: warning: unset value: $$ [-Wmidrule-values]
183 input.y:13.26-41: warning: unset value: $$ [-Wmidrule-values]
184 ]]])[[input.y:13.10-62: warning: unset value: $]$[ [-Wother]
185 input.y:13.10-62: warning: unused value: $]3[ [-Wother]
186 input.y:13.10-62: warning: unused value: $]5[ [-Wother]
187 ]]m4_ifval($2, [[[input.y:14.14-16: warning: unset value: $$ [-Wmidrule-values]
188 ]]])[[input.y:14.10-49: warning: unset value: $]$[ [-Wother]
189 input.y:14.10-49: warning: unused value: $]3[ [-Wother]
190 input.y:14.10-49: warning: unused value: $]5[ [-Wother]
191 input.y:15.10-37: warning: unset value: $]$[ [-Wother]
192 input.y:15.10-37: warning: unused value: $]3[ [-Wother]
193 input.y:15.10-37: warning: unused value: $]5[ [-Wother]
194 input.y:17.10-58: warning: unset value: $]$[ [-Wother]
195 input.y:17.10-58: warning: unused value: $]1[ [-Wother]
196 ]]m4_ifval($2, [[[input.y:17.10-58: warning: unused value: $]2[ [-Wmidrule-values]
197 ]]])[[input.y:17.10-58: warning: unused value: $]3[ [-Wother]
198 ]]m4_ifval($2, [[[input.y:17.10-58: warning: unused value: $]4[ [-Wmidrule-values]
199 ]]])[[input.y:17.10-58: warning: unused value: $]5[ [-Wother]
200 input.y:18.10-72: warning: unset value: $]$[ [-Wother]
201 input.y:18.10-72: warning: unused value: $]1[ [-Wother]
202 input.y:18.10-72: warning: unused value: $]3[ [-Wother]
203 ]]m4_ifval($2, [[[input.y:18.10-72: warning: unused value: $]4[ [-Wmidrule-values]
204 ]]])[[input.y:18.10-72: warning: unused value: $]5[ [-Wother]
205 ]]m4_ifval($2, [[[input.y:20.10-55: warning: unused value: $]3[ [-Wmidrule-values]
206 ]]])[[input.y:21.10-68: warning: unset value: $]$[ [-Wother]
207 input.y:21.10-68: warning: unused value: $]1[ [-Wother]
208 input.y:21.10-68: warning: unused value: $]2[ [-Wother]
209 ]]m4_ifval($2, [[[input.y:21.10-68: warning: unused value: $]4[ [-Wmidrule-values]
213 ## --------------- ##
215 ## --------------- ##
217 AT_SETUP([Unused values])
218 AT_CHECK_UNUSED_VALUES
219 AT_CHECK_UNUSED_VALUES(, [1])
223 ## ------------------------------------------ ##
224 ## Unused values before symbol declarations. ##
225 ## ------------------------------------------ ##
227 AT_SETUP([Unused values before symbol declarations])
228 AT_CHECK_UNUSED_VALUES([1])
229 AT_CHECK_UNUSED_VALUES([1], [1])
233 ## --------------------------------------------- ##
234 ## Default %printer and %destructor redeclared. ##
235 ## --------------------------------------------- ##
237 AT_SETUP([Default %printer and %destructor redeclared])
240 [[%destructor { destroy ($$); } <*> <*>
241 %printer { print ($$); } <*> <*>
243 %destructor { destroy ($$); } <*>
244 %printer { print ($$); } <*>
246 %destructor { destroy ($$); } <> <>
247 %printer { print ($$); } <> <>
249 %destructor { destroy ($$); } <>
250 %printer { print ($$); } <>
256 %destructor { destroy ($$); } <*>;
257 %printer { print ($$); } <*>;
259 %destructor { destroy ($$); } <>;
260 %printer { print ($$); } <>;
263 AT_BISON_CHECK([input.y], [1], [],
264 [[input.y:1.13-29: error: %destructor redeclaration for <*>
265 input.y:1.13-29: previous declaration
266 input.y:2.10-24: error: %printer redeclaration for <*>
267 input.y:2.10-24: previous declaration
268 input.y:4.13-29: error: %destructor redeclaration for <*>
269 input.y:1.13-29: previous declaration
270 input.y:5.10-24: error: %printer redeclaration for <*>
271 input.y:2.10-24: previous declaration
272 input.y:7.13-29: error: %destructor redeclaration for <>
273 input.y:7.13-29: previous declaration
274 input.y:8.10-24: error: %printer redeclaration for <>
275 input.y:8.10-24: previous declaration
276 input.y:10.13-29: error: %destructor redeclaration for <>
277 input.y:7.13-29: previous declaration
278 input.y:11.10-24: error: %printer redeclaration for <>
279 input.y:8.10-24: previous declaration
280 input.y:17.13-29: error: %destructor redeclaration for <*>
281 input.y:4.13-29: previous declaration
282 input.y:18.10-24: error: %printer redeclaration for <*>
283 input.y:5.10-24: previous declaration
284 input.y:20.13-29: error: %destructor redeclaration for <>
285 input.y:10.13-29: previous declaration
286 input.y:21.10-24: error: %printer redeclaration for <>
287 input.y:11.10-24: previous declaration
293 ## ---------------------------------------------- ##
294 ## Per-type %printer and %destructor redeclared. ##
295 ## ---------------------------------------------- ##
297 AT_SETUP([Per-type %printer and %destructor redeclared])
300 [[%destructor { destroy ($$); } <field1> <field2>
301 %printer { print ($$); } <field1> <field2>
303 %destructor { destroy ($$); } <field1> <field1>
304 %printer { print ($$); } <field2> <field2>
310 %destructor { destroy ($$); } <field2> <field1>;
311 %printer { print ($$); } <field2> <field1>;
314 AT_BISON_CHECK([input.y], [1], [],
315 [[input.y:4.13-29: error: %destructor redeclaration for <field1>
316 input.y:1.13-29: previous declaration
317 input.y:4.13-29: error: %destructor redeclaration for <field1>
318 input.y:4.13-29: previous declaration
319 input.y:5.10-24: error: %printer redeclaration for <field2>
320 input.y:2.10-24: previous declaration
321 input.y:5.10-24: error: %printer redeclaration for <field2>
322 input.y:5.10-24: previous declaration
323 input.y:11.13-29: error: %destructor redeclaration for <field1>
324 input.y:4.13-29: previous declaration
325 input.y:11.13-29: error: %destructor redeclaration for <field2>
326 input.y:1.13-29: previous declaration
327 input.y:12.10-24: error: %printer redeclaration for <field1>
328 input.y:2.10-24: previous declaration
329 input.y:12.10-24: error: %printer redeclaration for <field2>
330 input.y:5.10-24: previous declaration
335 ## ------------------- ##
336 ## Undefined symbols. ##
337 ## ------------------- ##
339 AT_SETUP([Undefined symbols])
342 [[%printer {} foo baz
349 AT_BISON_CHECK([input.y], [1], [],
350 [[input.y:2.16-18: error: symbol bar is used, but is not defined as a token and has no rules
351 input.y:1.17-19: warning: symbol baz is used, but is not defined as a token and has no rules [-Wother]
352 input.y:1.13-15: warning: symbol foo is used, but is not defined as a token and has no rules [-Wother]
353 input.y:3.13-15: warning: symbol qux is used, but is not defined as a token and has no rules [-Wother]
359 ## ----------------------------------------------------- ##
360 ## Unassociated types used for a printer or destructor. ##
361 ## ----------------------------------------------------- ##
363 AT_SETUP([Unassociated types used for a printer or destructor])
366 [[%token <type1> tag1
369 %printer { } <type1> <type3>
370 %destructor { } <type2> <type4>
380 AT_BISON_CHECK([input.y], [0], [],
381 [[input.y:4.22-28: warning: type <type3> is used, but is not associated to any symbol [-Wother]
382 input.y:5.25-31: warning: type <type4> is used, but is not associated to any symbol [-Wother]
388 ## --------------------------------- ##
389 ## Useless printers or destructors. ##
390 ## --------------------------------- ##
392 AT_SETUP([Useless printers or destructors])
394 # AT_TEST([INPUT], [STDERR])
395 # --------------------------
396 m4_pushdef([AT_TEST],
397 [AT_DATA([[input.y]],
400 AT_BISON_CHECK([input.y], [0], [], [$2
403 AT_TEST([[%token <type1> token1
404 %token <type2> token2
405 %token <type3> token3
406 %token <type4> token4
407 %token <type5> token51 token52
408 %token <type6> token61 token62
409 %token <type7> token7
412 %destructor {} token2
414 %destructor {} token61
419 %destructor {} <type2>
421 %destructor {} <type4>
424 %destructor {} <type6>
426 %destructor {} <type7>
430 [[input.y:16.13-19: warning: useless %printer for type <type1> [-Wother]
431 input.y:17.16-22: warning: useless %destructor for type <type2> [-Wother]]])
433 # If everybody is typed, <> is useless.
434 AT_TEST([[%type <type> exp
439 [[input.y:3.13-14: warning: useless %printer for type <> [-Wother]]])
441 # If nobody is typed, <*> is useless.
446 [[input.y:2.16-18: warning: useless %printer for type <*> [-Wother]]])
453 ## ---------------------------------------- ##
454 ## Unused values with default %destructor. ##
455 ## ---------------------------------------- ##
457 AT_SETUP([Unused values with default %destructor])
460 [[%destructor { destroy ($$); } <>
465 start: end end tagged tagged { $<tag>1; $3; } ;
470 AT_BISON_CHECK([input.y], [0], [],
471 [[input.y:6.8-45: warning: unset value: $$ [-Wother]
472 input.y:6.8-45: warning: unused value: $2 [-Wother]
473 input.y:7.6-8: warning: unset value: $$ [-Wother]
477 [[%destructor { destroy ($$); } <*>
482 start: end end tagged tagged { $<tag>1; $3; } ;
487 AT_BISON_CHECK([input.y], [0], [],
488 [[input.y:6.8-45: warning: unused value: $4 [-Wother]
489 input.y:8.9-11: warning: unset value: $$ [-Wother]
495 ## ----------------------------------------- ##
496 ## Unused values with per-type %destructor. ##
497 ## ----------------------------------------- ##
499 AT_SETUP([Unused values with per-type %destructor])
502 [[%destructor { destroy ($$); } <field1>
503 %type <field1> start end
507 start: end end { $1; } ;
511 AT_BISON_CHECK([input.y], [0], [],
512 [[input.y:6.8-22: warning: unset value: $$ [-Wother]
513 input.y:6.8-22: warning: unused value: $2 [-Wother]
514 input.y:7.6-8: warning: unset value: $$ [-Wother]
520 ## ---------------------- ##
521 ## Incompatible Aliases. ##
522 ## ---------------------- ##
524 AT_SETUP([Incompatible Aliases])
531 %destructor {bar} foo
536 %destructor {baz} "foo"
543 AT_BISON_CHECK([input.y], [1], [],
544 [[input.y:8.7-11: error: %type redeclaration for foo
545 input.y:3.7-11: previous declaration
546 input.y:10.13-17: error: %destructor redeclaration for foo
547 input.y:5.13-17: previous declaration
548 input.y:9.10-14: error: %printer redeclaration for foo
549 input.y:4.10-14: previous declaration
550 input.y:11.1-5: error: %left redeclaration for foo
551 input.y:6.1-5: previous declaration
558 ## ----------------------- ##
559 ## Torturing the Scanner. ##
560 ## ----------------------- ##
562 # Be sure to compile and run, so that the C compiler checks what
565 AT_SETUP([Torturing the Scanner])
567 AT_BISON_OPTION_PUSHDEFS
568 AT_DATA([input.y], [])
569 AT_BISON_CHECK([input.y], [1], [],
570 [[input.y:1.1: error: syntax error, unexpected end of file
577 AT_BISON_CHECK([input.y], [1], [],
578 [[input.y:1.1-2: error: syntax error, unexpected {...}
582 AT_DATA_GRAMMAR([input.y],
584 /* This is seen in GCC: a %{ and %} in middle of a comment. */
585 const char *foo = "So %{ and %} can be here too.";
588 /* These examples test Bison while not stressing C compilers too much.
589 Many C compilers mishandle backslash-newlines, so this part of the
590 test is inside "#if 0". The comment and string are written so that
591 the "#endif" will be seen regardless of the C compiler bugs that we
594 HP C (as of late 2002) mishandles *\[newline]\[newline]/ within a
597 The Apple Darwin compiler (as of late 2002) mishandles
598 \\[newline]' within a character constant.
603 * A comment with backslash-newlines in it. %} *\
606 /* { Close the above comment, if the C compiler mishandled it. */
609 " A string with backslash-newlines in it %{ %} \\
613 char apostrophe = '\'';
620 /* %{ and %} can be here too. */
623 /* Exercise pre-prologue dependency to %union. */
627 /* Exercise M4 quoting: '@:>@@:>@', 0. */
629 /* Also exercise %union. */
632 value ival; /* A comment to exercise an old bug. */
636 /* Exercise post-prologue dependency to %union. */
638 static YYSTYPE value_as_yystype (value val);
640 /* Exercise quotes in declarations. */
641 char quote[] = "@:>@@:>@,";
651 /* Exercise quotes in strings. */
652 %token FAKE "fake @<:@@:>@ \a\b\f\n\r\t\v\"\'\?\\\u005B\U0000005c ??!??'??(??)??-??/??<??=??> \x1\1"
655 /* Exercise M4 quoting: '@:>@@:>@', @<:@, 1. */
656 exp: '@<:@' '\1' two '$' '@' '{' oline output.or.oline.opt
658 /* Exercise quotes in braces. */
659 char tmp[] = "@<:@%c@:>@,\n";
664 two: '\x000000000000000000000000000000000000000000000000000000000000000000002';
665 oline: '@' 'o' 'l' 'i' 'n' 'e' '@' '_' '_' 'o' 'l' 'i' 'n' 'e' '_' '_';
666 output.or.oline.opt: ;|oline;;|output;;;
667 output: '#' 'o' 'u' 't' 'p' 'u' 't' ' ';
669 /* Exercise M4 quoting: '@:>@@:>@', @<:@, 2. */
672 value_as_yystype (value val)
682 static char const input[] = "@<:@\1\2$@{@oline@__@&t@oline__\
685 static size_t toknum;
686 assert (toknum < sizeof input);
687 yylval = value_as_yystype (input[toknum]);
688 return input[toknum++];
692 # Pacify Emacs'font-lock-mode: "
706 AT_BISON_OPTION_POPDEFS
708 AT_BISON_CHECK([-d -v -o input.c input.y])
709 AT_COMPILE([input.o])
711 AT_COMPILE([input], [input.o main.o])
712 AT_PARSER_CHECK([./input], 0,
719 ## ---------------------- ##
720 ## Typed symbol aliases. ##
721 ## ---------------------- ##
723 AT_SETUP([Typed symbol aliases])
725 # Bison 2.0 broke typed symbol aliases - ensure they work.
727 AT_DATA_GRAMMAR([input.y],
732 %token <val> MY_TOKEN "MY TOKEN"
739 AT_BISON_CHECK([-o input.c input.y])
748 m4_define([AT_CHECK_REQUIRE],
749 [AT_SETUP([Require $1])
750 AT_DATA_GRAMMAR([input.y],
755 AT_BISON_CHECK([-o input.c input.y], $2, [], ignore)
759 AT_CHECK_REQUIRE(1.0, 0)
760 AT_CHECK_REQUIRE(AT_PACKAGE_VERSION, 0)
761 ## FIXME: Some day augment this version number.
762 AT_CHECK_REQUIRE(100.0, 63)
765 ## ------------------------------------- ##
766 ## String aliases for character tokens. ##
767 ## ------------------------------------- ##
769 AT_SETUP([String aliases for character tokens])
771 # Bison once thought a character token and its alias were different
772 # symbols with the same user token number.
774 AT_DATA_GRAMMAR([input.y],
781 AT_BISON_CHECK([-o input.c input.y])
792 AT_BISON_OPTION_PUSHDEFS
793 AT_DATA_GRAMMAR([input.y],
795 %token WITHOUT_DASH "WITHOUT-DASH"
797 %token WITHOUT_PERIOD "WITHOUT.PERIOD"
803 start: with-dash without_dash with.period without_period;
804 with-dash: WITH-DASH;
805 without_dash: "WITHOUT-DASH";
806 with.period: WITH.PERIOD;
807 without_period: "WITHOUT.PERIOD";
812 AT_BISON_OPTION_POPDEFS
814 # POSIX Yacc accept periods, but not dashes.
815 AT_BISON_CHECK([--yacc -Wno-error input.y], [], [],
816 [[input.y:9.8-16: warning: POSIX Yacc forbids dashes in symbol names: WITH-DASH [-Wyacc]
817 input.y:18.8-16: warning: POSIX Yacc forbids dashes in symbol names: with-dash [-Wyacc]
820 # So warn about them.
821 AT_BISON_CHECK([-Wyacc input.y], [], [],
822 [[input.y:9.8-16: warning: POSIX Yacc forbids dashes in symbol names: WITH-DASH [-Wyacc]
823 input.y:18.8-16: warning: POSIX Yacc forbids dashes in symbol names: with-dash [-Wyacc]
826 # Dashes are fine for GNU Bison.
827 AT_BISON_CHECK([-o input.c input.y])
829 # Make sure we don't export silly token identifiers with periods or dashes.
830 AT_COMPILE([input.o])
833 # Periods are genuine letters, they can start identifiers.
834 # Digits and dashes cannot.
835 AT_DATA_GRAMMAR([input.y],
843 AT_BISON_CHECK([-o input.c input.y], [1], [],
844 [[input.y:10.10: error: invalid character: '-'
845 input.y:11.10-16: error: invalid identifier: '1NV4L1D'
846 input.y:12.10: error: invalid character: '-'
852 ## ----------------- ##
853 ## Numbered tokens. ##
854 ## ----------------- ##
856 AT_SETUP([Numbered tokens])
858 AT_DATA_GRAMMAR([redecl.y],
859 [[%token DECIMAL_1 11259375
860 HEXADECIMAL_1 0xabcdef
861 HEXADECIMAL_2 0xFEDCBA
864 start: DECIMAL_1 HEXADECIMAL_2;
867 AT_BISON_CHECK([redecl.y], [1], [],
868 [[redecl.y:10.10-22: error: user token number 11259375 redeclaration for HEXADECIMAL_1
869 redecl.y:9.8-16: previous declaration for DECIMAL_1
870 redecl.y:12.10-18: error: user token number 16702650 redeclaration for DECIMAL_2
871 redecl.y:11.10-22: previous declaration for HEXADECIMAL_2
874 AT_DATA_GRAMMAR([too-large.y],
875 [[%token TOO_LARGE_DEC 999999999999999999999
876 TOO_LARGE_HEX 0xFFFFFFFFFFFFFFFFFFF
878 start: TOO_LARGE_DEC TOO_LARGE_HEX
882 AT_BISON_CHECK([too-large.y], [1], [],
883 [[too-large.y:9.22-42: error: integer out of range: '999999999999999999999'
884 too-large.y:10.24-44: error: integer out of range: '0xFFFFFFFFFFFFFFFFFFF'
890 ## --------------------- ##
891 ## Unclosed constructs. ##
892 ## --------------------- ##
894 AT_SETUP([Unclosed constructs])
896 # Bison's scan-gram.l once forgot to STRING_FINISH some unclosed
897 # constructs, so they were prepended to whatever it STRING_GROW'ed
898 # next. It also threw them away rather than returning them to the
899 # parser. The effect was confusing subsequent error messages.
904 %token AB "ab" // Used to complain that "ab" was already used.
907 %token TICK_TWELVE "'12" // Used to complain that "'12" was already used.
913 // Used to report a syntax error because it didn't see any kind of symbol
919 // Used to report a syntax error because it didn't see braced code.
920 %destructor { free ($$)
923 AT_BISON_CHECK([-o input.c input.y], 1, [],
924 [[input.y:1.10-2.0: error: missing '"' at end of line
925 input.y:4.10-5.0: error: missing "'" at end of line
926 input.y:14.11-15.0: error: missing "'" at end of line
927 input.y:16.11-17.0: error: missing '"' at end of line
928 input.y:19.13-20.0: error: missing '}' at end of file
929 input.y:20.1: error: syntax error, unexpected end of file
935 ## ------------------------- ##
936 ## %start after first rule. ##
937 ## ------------------------- ##
939 AT_SETUP([%start after first rule])
941 # Bison once complained that a %start after the first rule was a
942 # redeclaration of the start symbol.
951 AT_BISON_CHECK([-o input.c input.y])
956 ## --------------------- ##
957 ## %prec takes a token. ##
958 ## --------------------- ##
960 AT_SETUP([%prec takes a token])
962 # Bison once allowed %prec sym where sym was a nonterminal.
966 start: PREC %prec PREC ;
970 AT_BISON_CHECK([input.y], [1], [],
971 [[input.y:3.1-4: error: rule given for PREC, which is a token
977 ## ------------------------------- ##
978 ## %prec's token must be defined. ##
979 ## ------------------------------- ##
981 AT_SETUP([[%prec's token must be defined]])
983 # According to POSIX, a %prec token must be defined separately.
990 AT_BISON_CHECK([[input.y]], [[0]], [],
991 [[input.y:2.8-17: warning: token for %prec is not defined: PREC [-Wother]
997 ## -------------------------------- ##
998 ## Reject unused %code qualifiers. ##
999 ## -------------------------------- ##
1001 AT_SETUP([Reject unused %code qualifiers])
1003 AT_DATA([input-c.y],
1011 AT_BISON_CHECK([[input-c.y]], [[1]], [],
1012 [[input-c.y:1.7: error: %code qualifier 'q' is not used
1013 input-c.y:2.7-9: error: %code qualifier 'bad' is not used
1014 input-c.y:3.7-9: error: %code qualifier 'bad' is not used
1015 input-c.y:4.7-12: error: %code qualifier 'format' is not used
1018 AT_DATA([input-c-glr.y],
1025 AT_BISON_CHECK([[input-c-glr.y]], [[1]], [],
1026 [[input-c-glr.y:1.7: error: %code qualifier 'q' is not used
1027 input-c-glr.y:2.7-9: error: %code qualifier 'bad' is not used
1028 input-c-glr.y:3.8-10: error: %code qualifier 'bad' is not used
1031 AT_DATA([input-c++.y],
1038 AT_BISON_CHECK([[input-c++.y]], [[1]], [],
1039 [[input-c++.y:1.7: error: %code qualifier 'q' is not used
1040 input-c++.y:2.7-9: error: %code qualifier 'bad' is not used
1041 input-c++.y:3.8: error: %code qualifier 'q' is not used
1044 AT_DATA([input-c++-glr.y],
1051 AT_BISON_CHECK([[input-c++-glr.y]], [[1]], [],
1052 [[input-c++-glr.y:1.7-9: error: %code qualifier 'bad' is not used
1053 input-c++-glr.y:2.7: error: %code qualifier 'q' is not used
1054 input-c++-glr.y:3.7: error: %code qualifier 'q' is not used
1057 AT_DATA([special-char-@@.y],
1064 AT_BISON_CHECK([[special-char-@@.y]], [[1]], [],
1065 [[special-char-@@.y:1.7-9: error: %code qualifier 'bad' is not used
1066 special-char-@@.y:2.7: error: %code qualifier 'q' is not used
1067 special-char-@@.y:3.7: error: %code qualifier 'q' is not used
1070 AT_DATA([special-char-@:>@.y],
1077 AT_BISON_CHECK([[special-char-@:>@.y]], [[1]], [],
1078 [[special-char-@:>@.y:1.7-9: error: %code qualifier 'bad' is not used
1079 special-char-@:>@.y:2.7: error: %code qualifier 'q' is not used
1080 special-char-@:>@.y:3.7: error: %code qualifier 'q' is not used
1086 ## ---------------- ##
1087 ## %define errors. ##
1088 ## ---------------- ##
1090 AT_SETUP([%define errors])
1092 AT_DATA([input-redefined.y],
1093 [[%define var "value1"
1094 %define var "value1"
1095 %define var "value2"
1096 %define special1 "@:>@"
1097 %define special2 "@<:@"
1102 AT_BISON_CHECK([[input-redefined.y]], [[1]], [],
1103 [[input-redefined.y:2.9-11: error: %define variable 'var' redefined
1104 input-redefined.y:1.9-11: previous definition
1105 input-redefined.y:3.10-12: error: %define variable 'var' redefined
1106 input-redefined.y:2.9-11: previous definition
1109 AT_DATA([input-unused.y],
1110 [[%define var "value"
1115 AT_BISON_CHECK([[input-unused.y]], [[1]], [],
1116 [[input-unused.y:1.9-11: error: %define variable 'var' is not used
1122 ## ----------------------------------- ##
1123 ## %define, --define, --force-define. ##
1124 ## ----------------------------------- ##
1126 AT_SETUP([[%define, --define, --force-define]])
1129 [[m4@&t@_divert_push(0)@
1130 @output(b4_parser_file_name@)@
1131 [var-dd: ]b4_percent_define_get([[var-dd]])[
1132 var-ff: ]b4_percent_define_get([[var-ff]])[
1133 var-dfg: ]b4_percent_define_get([[var-dfg]])[
1134 var-fd: ]b4_percent_define_get([[var-fd]])
1135 m4@&t@_divert_pop(0)
1137 AT_DATA([[input.y]],
1138 [[%define var-dfg "gram"
1142 AT_BISON_CHECK([[-Dvar-dd=cmd-d1 -Dvar-dd=cmd-d2 \
1143 -Fvar-ff=cmd-f1 -Fvar-ff=cmd-f2 \
1144 -Dvar-dfg=cmd-d -Fvar-dfg=cmd-f \
1145 -Fvar-fd=cmd-f -Dvar-fd=cmd-d \
1146 --skeleton ./skel.c input.y]])
1147 AT_CHECK([[cat input.tab.c]], [[0]],
1154 AT_DATA([[input-dg.y]],
1155 [[%define var "gram"
1159 AT_BISON_CHECK([[-Dvar=cmd-d input-dg.y]], [[1]], [],
1160 [[input-dg.y:1.9-11: error: %define variable 'var' redefined
1161 <command line>:2: previous definition
1164 AT_DATA([[input-unused.y]],
1168 AT_BISON_CHECK([[-Dunused-d -Funused-f input-unused.y]], [[1]], [],
1169 [[<command line>:2: error: %define variable 'unused-d' is not used
1170 <command line>:3: error: %define variable 'unused-f' is not used
1175 ## --------------------------- ##
1176 ## %define Boolean variables. ##
1177 ## --------------------------- ##
1179 AT_SETUP([[%define Boolean variables]])
1183 %define public "maybe"
1184 %define parser_class_name "Input"
1189 AT_BISON_CHECK([[Input.y]], [1], [],
1190 [[Input.y:2.9-14: error: invalid value for %define Boolean variable 'public'
1195 ## ------------------------ ##
1196 ## %define enum variables. ##
1197 ## ------------------------ ##
1199 AT_SETUP([[%define enum variables]])
1202 AT_DATA([[input.y]],
1203 [[%define lr.default-reduction bogus
1207 AT_BISON_CHECK([[input.y]], [[1]], [[]],
1208 [[input.y:1.9-28: error: invalid value for %define variable 'lr.default-reduction': 'bogus'
1209 input.y:1.9-28: accepted value: 'most'
1210 input.y:1.9-28: accepted value: 'consistent'
1211 input.y:1.9-28: accepted value: 'accepting'
1215 # FIXME: these should be indented, but we shouldn't mess with the m4 yet
1216 AT_DATA([[input.y]],
1217 [[%define api.push-pull neither
1221 AT_BISON_CHECK([[input.y]], [1], [],
1222 [[input.y:1.9-21: error: invalid value for %define variable 'api.push-pull': 'neither'
1223 input.y:1.9-21: accepted value: 'pull'
1224 input.y:1.9-21: accepted value: 'push'
1225 input.y:1.9-21: accepted value: 'both'
1230 ## -------------------------------- ##
1231 ## %define backward compatibility. ##
1232 ## -------------------------------- ##
1234 AT_SETUP([[%define backward compatibility]])
1236 # The error messages tell us whether underscores in these variables are
1237 # being converted to dashes.
1239 AT_DATA([[input.y]],
1240 [[%define api.push_pull "neither"
1244 AT_BISON_CHECK([[input.y]], [1], [],
1245 [[input.y:1.9-21: warning: deprecated %define variable name: 'api.push_pull', use 'api.push-pull' [-Wdeprecated]
1246 input.y:1.9-21: error: invalid value for %define variable 'api.push-pull': 'neither'
1247 input.y:1.9-21: accepted value: 'pull'
1248 input.y:1.9-21: accepted value: 'push'
1249 input.y:1.9-21: accepted value: 'both'
1252 AT_DATA([[input.y]],
1253 [[%define lr.keep_unreachable_states maybe
1257 AT_BISON_CHECK([[input.y]], [1], [],
1258 [[input.y:1.9-34: warning: deprecated %define variable name: 'lr.keep_unreachable_states', use 'lr.keep-unreachable-state' [-Wdeprecated]
1259 input.y:1.9-34: error: invalid value for %define Boolean variable 'lr.keep-unreachable-state'
1262 AT_DATA([[input.y]],
1263 [[%define namespace "foo"
1264 %define api.namespace "foo"
1268 AT_BISON_CHECK([[input.y]], [1], [],
1269 [[input.y:1.9-17: warning: deprecated %define variable name: 'namespace', use 'api.namespace' [-Wdeprecated]
1270 input.y:2.9-21: error: %define variable 'api.namespace' redefined
1271 input.y:1.9-17: previous definition
1274 AT_DATA([[input.y]],
1275 [[%define foo_bar "baz"
1279 AT_BISON_CHECK([[input.y]], [[1]], [],
1280 [[input.y:1.9-15: error: %define variable 'foo_bar' is not used
1285 ## ------------------------- ##
1286 ## Unused %define api.pure. ##
1287 ## ------------------------- ##
1289 AT_SETUP([[Unused %define api.pure]])
1291 # AT_CHECK_API_PURE(DECLS, VALUE)
1292 # -------------------------------
1293 # Make sure Bison reports that `%define api.pure VALUE' is unused when DECLS
1295 m4_define([AT_CHECK_API_PURE],
1297 AT_DATA([[input.y]],
1298 [[%define api.pure ]$2[
1304 AT_BISON_CHECK([[input.y]], [[1]], [],
1305 [[input.y:1.9-16: error: %define variable 'api.pure' is not used
1309 AT_CHECK_API_PURE([[%language "c++" %defines]], [[]])
1310 AT_CHECK_API_PURE([[%language "c++" %defines]], [[false]])
1311 AT_CHECK_API_PURE([[%language "c++" %defines %glr-parser]], [[""]])
1312 AT_CHECK_API_PURE([[%language "c++" %defines %glr-parser]], [[false]])
1313 AT_CHECK_API_PURE([[%language "java"]], [[true]])
1314 AT_CHECK_API_PURE([[%language "java"]], [[false]])
1318 ## -------------------------------- ##
1319 ## C++ namespace reference errors. ##
1320 ## -------------------------------- ##
1322 AT_SETUP([[C++ namespace reference errors]])
1324 # AT_CHECK_NAMESPACE_ERROR(NAMESPACE-DECL, ERROR, [ERROR], ...)
1325 # -------------------------------------------------------------
1326 # Make sure Bison reports all ERROR's for %define namespace "NAMESPACE-DECL".
1327 m4_define([AT_CHECK_NAMESPACE_ERROR],
1329 AT_DATA([[input.y]],
1332 %define api.namespace "]$1["
1337 AT_BISON_CHECK([[input.y]], [1], [],
1338 [m4_foreach([b4_arg], m4_dquote(m4_shift($@)),
1339 [[input.y:3.9-21: error: ]b4_arg[
1343 AT_CHECK_NAMESPACE_ERROR([[]],
1344 [[namespace reference is empty]])
1345 AT_CHECK_NAMESPACE_ERROR([[ ]],
1346 [[namespace reference is empty]])
1347 AT_CHECK_NAMESPACE_ERROR([[foo::::bar]],
1348 [[namespace reference has consecutive "::"]])
1349 AT_CHECK_NAMESPACE_ERROR([[foo:: ::bar]],
1350 [[namespace reference has consecutive "::"]])
1351 AT_CHECK_NAMESPACE_ERROR([[::::bar]],
1352 [[namespace reference has consecutive "::"]])
1353 AT_CHECK_NAMESPACE_ERROR([[:: ::bar]],
1354 [[namespace reference has consecutive "::"]])
1355 AT_CHECK_NAMESPACE_ERROR([[foo::bar:: ::]],
1356 [[namespace reference has consecutive "::"]],
1357 [[namespace reference has a trailing "::"]])
1358 AT_CHECK_NAMESPACE_ERROR([[foo::bar::]],
1359 [[namespace reference has a trailing "::"]])
1360 AT_CHECK_NAMESPACE_ERROR([[foo::bar:: ]],
1361 [[namespace reference has a trailing "::"]])
1362 AT_CHECK_NAMESPACE_ERROR([[::]],
1363 [[namespace reference has a trailing "::"]])
1367 ## ------------------------ ##
1368 ## Bad character literals. ##
1369 ## ------------------------ ##
1371 # Bison used to accept character literals that were empty or contained
1372 # too many characters.
1374 # FIXME: AT_DATA or some variant of AT_DATA may eventually permit
1375 # the final newline to be omitted. See the threads starting at
1376 # <http://lists.gnu.org/archive/html/bison-patches/2009-07/msg00019.html>.
1378 AT_SETUP([[Bad character literals]])
1385 AT_CHECK([[$PERL -e "print 'start: \'';" >> empty.y || exit 77]])
1387 AT_BISON_CHECK([empty.y], [1], [],
1388 [[empty.y:2.8-9: warning: empty character literal [-Wother]
1389 empty.y:3.8-4.0: warning: empty character literal [-Wother]
1390 empty.y:3.8-4.0: error: missing "'" at end of line
1391 empty.y:4.8: warning: empty character literal [-Wother]
1392 empty.y:4.8: error: missing "'" at end of file
1400 AT_CHECK([[$PERL -e "print 'start: \'ab';" >> two.y || exit 77]])
1402 AT_BISON_CHECK([two.y], [1], [],
1403 [[two.y:2.8-11: warning: extra characters in character literal [-Wother]
1404 two.y:3.8-4.0: warning: extra characters in character literal [-Wother]
1405 two.y:3.8-4.0: error: missing "'" at end of line
1406 two.y:4.8-10: warning: extra characters in character literal [-Wother]
1407 two.y:4.8-10: error: missing "'" at end of file
1415 AT_CHECK([[$PERL -e "print 'start: \'abc';" >> three.y || exit 77]])
1417 AT_BISON_CHECK([three.y], [1], [],
1418 [[three.y:2.8-12: warning: extra characters in character literal [-Wother]
1419 three.y:3.8-4.0: warning: extra characters in character literal [-Wother]
1420 three.y:3.8-4.0: error: missing "'" at end of line
1421 three.y:4.8-11: warning: extra characters in character literal [-Wother]
1422 three.y:4.8-11: error: missing "'" at end of file
1427 ## ------------------------- ##
1428 ## Bad escapes in literals. ##
1429 ## ------------------------- ##
1431 AT_SETUP([[Bad escapes in literals]])
1435 start: '\777' '\0' '\xfff' '\x0'
1436 '\uffff' '\u0000' '\Uffffffff' '\U00000000'
1440 # It is not easy to create special characters, we cannot even trust tr.
1441 # Beside we cannot even expect "echo '\0'" to output two characters
1442 # (well three with \n): at least Bash 3.2 converts the two-character
1443 # sequence "\0" into a single NUL character.
1444 AT_CHECK([[$PERL -e 'print "start: \"\\\t\\\f\\\0\\\1\" ;";' >> input.y \
1447 AT_BISON_CHECK([input.y], [1], [],
1448 [[input.y:2.9-12: error: invalid number after \-escape: 777
1449 input.y:2.8-13: warning: empty character literal [-Wother]
1450 input.y:2.16-17: error: invalid number after \-escape: 0
1451 input.y:2.15-18: warning: empty character literal [-Wother]
1452 input.y:2.21-25: error: invalid number after \-escape: xfff
1453 input.y:2.20-26: warning: empty character literal [-Wother]
1454 input.y:2.29-31: error: invalid number after \-escape: x0
1455 input.y:2.28-32: warning: empty character literal [-Wother]
1456 input.y:3.9-14: error: invalid number after \-escape: uffff
1457 input.y:3.8-15: warning: empty character literal [-Wother]
1458 input.y:3.18-23: error: invalid number after \-escape: u0000
1459 input.y:3.17-24: warning: empty character literal [-Wother]
1460 input.y:3.27-36: error: invalid number after \-escape: Uffffffff
1461 input.y:3.26-37: warning: empty character literal [-Wother]
1462 input.y:3.40-49: error: invalid number after \-escape: U00000000
1463 input.y:3.39-50: warning: empty character literal [-Wother]
1464 input.y:4.9-10: error: invalid character after \-escape: ' '
1465 input.y:4.8-11: warning: empty character literal [-Wother]
1466 input.y:4.14-15: error: invalid character after \-escape: A
1467 input.y:4.13-16: warning: empty character literal [-Wother]
1468 input.y:5.9-16: error: invalid character after \-escape: \t
1469 input.y:5.17: error: invalid character after \-escape: \f
1470 input.y:5.18: error: invalid character after \-escape: \0
1471 input.y:5.19: error: invalid character after \-escape: \001
1476 ## ------------------------- ##
1477 ## LAC: Errors for %define. ##
1478 ## ------------------------- ##
1480 AT_SETUP([[LAC: Errors for %define]])
1482 AT_DATA([[input.y]],
1487 # parse.lac.* options are useless if LAC isn't actually activated.
1488 AT_BISON_CHECK([[-Dparse.lac.es-capacity-initial=1 input.y]],
1490 [[<command line>:2: error: %define variable 'parse.lac.es-capacity-initial' is not used
1492 AT_BISON_CHECK([[-Dparse.lac.memory-trace=full input.y]],
1494 [[<command line>:2: error: %define variable 'parse.lac.memory-trace' is not used
1499 ## --------------------------------------------- ##
1500 ## -Werror is not affected by -Wnone and -Wall. ##
1501 ## --------------------------------------------- ##
1503 AT_SETUP([[-Werror is not affected by -Wnone and -Wall]])
1505 AT_DATA([[input.y]],
1510 # -Werror is not enabled by -Wall or equivalent.
1511 AT_BISON_CHECK([[-Wall input.y]], [[0]], [[]],
1512 [[input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar [-Wyacc]
1514 AT_BISON_CHECK([[-W input.y]], [[0]], [[]],
1515 [[input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar [-Wyacc]
1517 AT_BISON_CHECK([[-Wno-none input.y]], [[0]], [[]],
1518 [[input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar [-Wyacc]
1521 # -Werror is not disabled by -Wnone or equivalent.
1522 AT_BISON_CHECK([[-Werror,none,yacc input.y]], [[1]], [[]], [[stderr]])
1523 AT_CHECK([[sed 's/^.*bison:/bison:/' stderr]], [[0]],
1524 [[input.y:2.1-7: error: POSIX Yacc forbids dashes in symbol names: foo-bar [-Werror=yacc]
1527 AT_BISON_CHECK([[-Werror,no-all,yacc input.y]], [[1]], [[]], [[experr]])
1532 ## ------------------------------------------------------ ##
1533 ## %name-prefix and %define api.prefix are incompatible. ##
1534 ## ------------------------------------------------------ ##
1536 AT_SETUP([[%name-prefix and %define api.prefix are incompatible]])
1538 # AT_TEST(DIRECTIVES, OPTIONS, ERROR-LOCATION)
1539 # --------------------------------------------
1540 m4_pushdef([AT_TEST],
1541 [AT_DATA([[input.y]],
1546 AT_BISON_CHECK([[$2 input.y]], [[1]], [[]],
1547 [[$3: error: '%name-prefix' and '%define api.prefix' cannot be used together
1551 AT_TEST([%define api.prefix foo %name-prefix "bar"], [], [input.y:1.9-18])
1552 AT_TEST([], [-Dapi.prefix=foo -p bar], [<command line>:2])
1553 AT_TEST([%name-prefix "bar"], [-Dapi.prefix=foo], [<command line>:2])
1554 AT_TEST([%define api.prefix foo], [-p bar], [input.y:1.9-18])
1556 m4_popdef([AT_TEST])
1561 ## -------------- ##
1563 ## -------------- ##
1565 AT_SETUP([[Stray $ or @]])
1567 # Give %printer and %destructor "<*> exp TOK" instead of "<*>" to
1568 # check that the warnings are reported once, not three times.
1570 AT_DATA_GRAMMAR([[input.y]],
1572 %token <TYPE> TOK TOK2
1573 %destructor { $%; @%; } <*> exp TOK;
1574 %initial-action { $%; @%; };
1575 %printer { $%; @%; } <*> exp TOK;
1577 exp: TOK { $%; @%; $$ = $1; };
1580 AT_BISON_CHECK([[input.y]], 0, [],
1581 [[input.y:11.19: warning: stray '$' [-Wother]
1582 input.y:11.23: warning: stray '@' [-Wother]
1583 input.y:12.19: warning: stray '$' [-Wother]
1584 input.y:12.23: warning: stray '@' [-Wother]
1585 input.y:13.19: warning: stray '$' [-Wother]
1586 input.y:13.23: warning: stray '@' [-Wother]
1587 input.y:15.19: warning: stray '$' [-Wother]
1588 input.y:15.23: warning: stray '@' [-Wother]
1595 ## ---------------- ##
1596 ## Code injection. ##
1597 ## ---------------- ##
1600 AT_SETUP([[Code injection]])
1602 m4_pattern_allow([^m4_errprintn$])
1606 # Try to have MACRO be run by bison.
1607 m4_pushdef([AT_TEST],
1608 [AT_DATA([[input.y]],
1609 [[%type <$1(DEAD %type)> exp
1610 %token <$1(DEAD %token)> a
1615 $<$1(DEAD %initial-action)>$
1620 $<$1(DEAD %printer)>$
1628 $1(DEAD %parse-param)
1636 $<$1(DEAD action 1)>$
1637 $<$1(DEAD action 2)>1
1638 $<$1(DEAD action 3)>name
1639 $<$1(DEAD action 4)>0
1644 # FIXME: Provide a means to iterate over all the skeletons.
1645 AT_BISON_CHECK([[-d input.y]])
1646 AT_BISON_CHECK([[-d -S glr.c input.y]])
1647 AT_BISON_CHECK([[-d -S lalr1.cc input.y]])
1648 AT_BISON_CHECK([[-d -S glr.cc input.y]])
1649 AT_BISON_CHECK([[ -S lalr1.java input.y]])
1652 AT_TEST([m4_errprintn])
1653 AT_TEST([@:>@m4_errprintn])
1655 m4_popdef([AT_TEST])
1659 ##----------------------- ##
1660 ## Deprecated directives. ##
1661 ## ---------------------- ##
1663 AT_SETUP([[Deprecated directives]])
1665 AT_KEYWORDS([[deprec]])
1667 AT_DATA_GRAMMAR([[input.y]],
1672 %file-prefix = "foo"
1690 AT_BISON_CHECK([[input.y]], [[0]], [[]],
1691 [[input.y:10.1-13: warning: deprecated directive: '%default_prec', use '%default-prec' [-Wdeprecated]
1692 input.y:11.1-14: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
1693 input.y:12.1-10: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
1694 input.y:13.1-14: warning: deprecated directive: '%file-prefix =', use '%file-prefix' [-Wdeprecated]
1695 input.y:14.1-15.2: warning: deprecated directive: '%file-prefix\n =', use '%file-prefix' [-Wdeprecated]
1696 input.y:17.1-19: warning: deprecated directive: '%fixed-output_files', use '%fixed-output-files' [-Wdeprecated]
1697 input.y:18.1-19: warning: deprecated directive: '%fixed_output-files', use '%fixed-output-files' [-Wdeprecated]
1698 input.y:20.1-13: warning: deprecated directive: '%name-prefix=', use '%name-prefix' [-Wdeprecated]
1699 input.y:21.1-16: warning: deprecated directive: '%no-default_prec', use '%no-default-prec' [-Wdeprecated]
1700 input.y:22.1-16: warning: deprecated directive: '%no_default-prec', use '%no-default-prec' [-Wdeprecated]
1701 input.y:23.1-9: warning: deprecated directive: '%no_lines', use '%no-lines' [-Wdeprecated]
1702 input.y:24.1-9: warning: deprecated directive: '%output =', use '%output' [-Wdeprecated]
1703 input.y:25.1-12: warning: deprecated directive: '%pure_parser', use '%pure-parser' [-Wdeprecated]
1704 input.y:26.1-12: warning: deprecated directive: '%token_table', use '%token-table' [-Wdeprecated]
1709 ## ---------------------------- ##
1710 ## Unput's effect on locations. ##
1711 ## ---------------------------- ##
1712 dnl When the scanner detects a deprecated construct, it unputs the correct
1713 dnl version, but it should *not* have any impact on the scanner cursor. If it
1714 dnl does, the locations of directives on the same line become erroneous.
1716 AT_SETUP([[Unput's effect on locations]])
1718 AT_KEYWORDS([[deprec]])
1720 AT_DATA_GRAMMAR([[input.y]],
1723 %expect_rr 42 %expect_rr 42
1725 %error_verbose %error_verbose
1730 AT_BISON_CHECK([[input.y]], [[1]], [[]],
1731 [[input.y:11.1-10: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
1732 input.y:11.15-24: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
1733 input.y:12.15-24: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
1734 input.y:13.1-14: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
1735 input.y:13.16-29: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
1736 input.y:13.11-21: error: %define variable 'parse.error' redefined
1737 input.y:13-6: previous definition
1738 input.y:14.16-29: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
1739 input.y:14.11-21: error: %define variable 'parse.error' redefined
1740 input.y:13.11-21: previous definition
1745 ##--------------------------- ##
1746 ## Non-deprecated directives. ##
1747 ## -------------------------- ##
1749 AT_SETUP([[Non-deprecated directives]])
1751 AT_KEYWORDS([[deprec]])
1753 AT_DATA_GRAMMAR([[input.y]],
1771 AT_BISON_CHECK([[input.y]], [[0]], [[]],
1772 [[input.y: warning: %expect-rr applies only to GLR parsers [-Wother]