]> git.saurik.com Git - bison.git/blame_incremental - tests/input.at
tests: remove stray debugging traces
[bison.git] / tests / input.at
... / ...
CommitLineData
1# Checking the Bison scanner. -*- Autotest -*-
2
3# Copyright (C) 2002-2013 Free Software Foundation, Inc.
4
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.
9#
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.
14#
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/>.
17
18AT_BANNER([[Input Processing.]])
19
20# Mostly test that we are robust to mistakes.
21
22
23## ----------------- ##
24## Invalid options. ##
25## ----------------- ##
26
27AT_SETUP([Invalid options])
28
29AT_DATA([input.y],
30[[%%
31exp: '0'
32]])
33
34# We used to accept these, as -f, --report and others were sharing
35# their code with -W.
36AT_BISON_CHECK([-ferror=caret input.y], [1], [], [ignore])
37AT_BISON_CHECK([--report=error=itemsets input.y], [1], [], [ignore])
38
39# We used to accept any character after "-Werror", instead of ensuring
40# this is "=".
41AT_BISON_CHECK([-Werror?all input.y], [1], [], [ignore])
42
43AT_CLEANUP
44
45
46## ---------------- ##
47## Invalid inputs. ##
48## ---------------- ##
49
50AT_SETUP([Invalid inputs])
51
52AT_DATA([input.y],
53[[\000\001\002\377?
54%%
55?
56default: 'a' }
57%&
58%a-does-not-exist
59%-
60%{
61]])
62AT_CHECK([[$PERL -pi -e 's/\\(\d{3})/chr(oct($1))/ge' input.y || exit 77]])
63
64AT_BISON_CHECK([input.y], [1], [],
65[[input.y:1.1-2: error: invalid characters: '\0\001\002\377?'
66input.y:3.1: error: invalid character: '?'
67input.y:4.14: error: invalid character: '}'
68input.y:5.1: error: invalid character: '%'
69input.y:5.2: error: invalid character: '&'
70input.y:6.1-17: error: invalid directive: '%a-does-not-exist'
71input.y:7.1: error: invalid character: '%'
72input.y:7.2: error: invalid character: '-'
73input.y:8.1-9.0: error: missing '%}' at end of file
74input.y:8.1-9.0: error: syntax error, unexpected %{...%}
75]])
76
77AT_CLEANUP
78
79
80AT_SETUP([Invalid inputs with {}])
81
82# We used to SEGV here. See
83# http://lists.gnu.org/archive/html/bug-bison/2005-07/msg00053.html
84
85AT_DATA([input.y],
86[[
87%destructor
88%initial-action
89%lex-param
90%parse-param
91%printer
92%union
93]])
94
95AT_BISON_CHECK([input.y], [1], [],
96[[input.y:3.1-15: error: syntax error, unexpected %initial-action, expecting {...}
97]])
98
99AT_CLEANUP
100
101
102
103## ------------ ##
104## Invalid $n. ##
105## ------------ ##
106
107AT_SETUP([Invalid $n and @n])
108
109AT_DATA([input.y],
110[[%%
111exp: %empty { $$ = $1 ; };
112exp: %empty { @$ = @1 ; };
113]])
114
115AT_BISON_CHECK([-fcaret input.y], [1], [],
116[[input.y:2.20-21: error: integer out of range: '$1'
117 exp: %empty { $$ = $1 ; };
118 ^^
119input.y:3.20-21: error: integer out of range: '@1'
120 exp: %empty { @$ = @1 ; };
121 ^^
122]])
123
124AT_CLEANUP
125
126
127## -------------- ##
128## Type Clashes. ##
129## -------------- ##
130
131AT_SETUP([Type Clashes])
132
133AT_DATA([input.y],
134[[%union { int bar; }
135%token foo
136%type <bar> exp
137%%
138exp: foo { $$; } foo { $2; } foo
139 | foo
140 | %empty
141 ;
142]])
143
144AT_BISON_CHECK([-fcaret input.y], [1], [],
145[[input.y:5.12-13: error: $$ for the midrule at $2 of 'exp' has no declared type
146 exp: foo { $$; } foo { $2; } foo
147 ^^
148input.y:5.24-25: error: $2 of 'exp' has no declared type
149 exp: foo { $$; } foo { $2; } foo
150 ^^
151input.y:5.6-32: warning: type clash on default action: <bar> != <> [-Wother]
152 exp: foo { $$; } foo { $2; } foo
153 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
154input.y:6.6-8: warning: type clash on default action: <bar> != <> [-Wother]
155 | foo
156 ^^^
157input.y:7.6-11: warning: empty rule for typed nonterminal, and no action [-Wother]
158 | %empty
159 ^^^^^^
160]])
161
162AT_CLEANUP
163
164
165# _AT_UNUSED_VALUES_DECLARATIONS()
166# --------------------------------
167# Generate the token, type, and destructor
168# declarations for the unused values tests.
169m4_define([_AT_UNUSED_VALUES_DECLARATIONS],
170[[[%token <integer> INT;
171%type <integer> a b c d e f g h i j k l;
172%destructor { destroy ($$); } INT a b c d e f g h i j k l;]]])
173
174
175# AT_CHECK_UNUSED_VALUES(DECLARATIONS_AFTER, CHECK_MIDRULE_VALUES)
176# ----------------------------------------------------------------
177# Generate a grammar to test unused values, compile it, run it. If
178# DECLARATIONS_AFTER is set, then the token, type, and destructor
179# declarations are generated after the rules rather than before. If
180# CHECK_MIDRULE_VALUES is set, then --warnings=midrule-values is set.
181m4_define([AT_CHECK_UNUSED_VALUES],
182[AT_DATA([input.y],
183m4_ifval($1, [
184
185
186], [_AT_UNUSED_VALUES_DECLARATIONS
187])[[%%
188start:
189 'a' a { $]2[; } | 'b' b { $]2[; } | 'c' c { $]2[; } | 'd' d { $]2[; }
190| 'e' e { $]2[; } | 'f' f { $]2[; } | 'g' g { $]2[; } | 'h' h { $]2[; }
191| 'i' i { $]2[; } | 'j' j { $]2[; } | 'k' k { $]2[; } | 'l' l { $]2[; }
192;
193
194a: INT | INT { } INT { } INT { };
195b: INT | %empty;
196c: INT | INT { $]1[; } INT { $<integer>2; } INT { $<integer>4; };
197d: INT | INT { } INT { $]1[; } INT { $<integer>2; };
198e: INT | INT { } INT { } INT { $]1[; };
199f: INT | INT { } INT { } INT { $]$[ = $]1[ + $]3[ + $]5[; };
200g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
201h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
202i: INT | INT INT { } { $]$[ = $]1[ + $]2[; };
203j: INT | INT INT { $<integer>$ = 1; } { $]$[ = $]1[ + $]2[; };
204k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
205l: INT | INT { $<integer>$ = $<integer>1; } INT { $<integer>$ = $<integer>2 + $<integer>3; } INT { $<integer>$ = $<integer>4 + $<integer>5; };]]m4_ifval($1, [
206_AT_UNUSED_VALUES_DECLARATIONS])
207)
208
209AT_BISON_CHECK(m4_ifval($2, [--warnings=midrule-values ])[-fcaret input.y],
210 [0], [],
211[[input.y:11.10-32: warning: unset value: $][$ [-Wother]
212 a: INT | INT { } INT { } INT { };
213 ^^^^^^^^^^^^^^^^^^^^^^^
214input.y:11.10-12: warning: unused value: $][1 [-Wother]
215 a: INT | INT { } INT { } INT { };
216 ^^^
217input.y:11.18-20: warning: unused value: $][3 [-Wother]
218 a: INT | INT { } INT { } INT { };
219 ^^^
220input.y:11.26-28: warning: unused value: $][5 [-Wother]
221 a: INT | INT { } INT { } INT { };
222 ^^^
223input.y:12.10-15: warning: empty rule for typed nonterminal, and no action [-Wother]
224 b: INT | %empty;
225 ^^^^^^
226]]m4_ifval($2, [[[input.y:13.14-20: warning: unset value: $][$ [-Wmidrule-values]
227 c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
228 ^^^^^^^
229input.y:13.26-41: warning: unset value: $][$ [-Wmidrule-values]
230 c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
231 ^^^^^^^^^^^^^^^^
232]]])[[input.y:13.10-62: warning: unset value: $][$ [-Wother]
233 c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
234 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
235input.y:13.22-24: warning: unused value: $][3 [-Wother]
236 c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
237 ^^^
238input.y:13.43-45: warning: unused value: $][5 [-Wother]
239 c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
240 ^^^
241]]m4_ifval($2, [[[input.y:14.14-16: warning: unset value: $][$ [-Wmidrule-values]
242 d: INT | INT { } INT { $][1; } INT { $<integer>2; };
243 ^^^
244]]])[[input.y:14.10-49: warning: unset value: $][$ [-Wother]
245 d: INT | INT { } INT { $][1; } INT { $<integer>2; };
246 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
247input.y:14.18-20: warning: unused value: $][3 [-Wother]
248 d: INT | INT { } INT { $][1; } INT { $<integer>2; };
249 ^^^
250input.y:14.30-32: warning: unused value: $][5 [-Wother]
251 d: INT | INT { } INT { $][1; } INT { $<integer>2; };
252 ^^^
253input.y:15.10-37: warning: unset value: $][$ [-Wother]
254 e: INT | INT { } INT { } INT { $][1; };
255 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
256input.y:15.18-20: warning: unused value: $][3 [-Wother]
257 e: INT | INT { } INT { } INT { $][1; };
258 ^^^
259input.y:15.27-29: warning: unused value: $][5 [-Wother]
260 e: INT | INT { } INT { } INT { $][1; };
261 ^^^
262input.y:17.10-58: warning: unset value: $][$ [-Wother]
263 g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
264 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
265input.y:17.10-12: warning: unused value: $][1 [-Wother]
266 g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
267 ^^^
268]]m4_ifval($2, [[[input.y:17.14-29: warning: unused value: $][2 [-Wmidrule-values]
269 g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
270 ^^^^^^^^^^^^^^^^
271]]])[[input.y:17.31-33: warning: unused value: $][3 [-Wother]
272 g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
273 ^^^
274]]m4_ifval($2, [[[input.y:17.35-50: warning: unused value: $][4 [-Wmidrule-values]
275 g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
276 ^^^^^^^^^^^^^^^^
277]]])[[input.y:17.52-54: warning: unused value: $][5 [-Wother]
278 g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
279 ^^^
280input.y:18.10-72: warning: unset value: $][$ [-Wother]
281 h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
282 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
283input.y:18.10-12: warning: unused value: $][1 [-Wother]
284 h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
285 ^^^
286input.y:18.31-33: warning: unused value: $][3 [-Wother]
287 h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
288 ^^^
289]]m4_ifval($2, [[[input.y:18.35-64: warning: unused value: $][4 [-Wmidrule-values]
290 h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
291 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
292]]])[[input.y:18.66-68: warning: unused value: $][5 [-Wother]
293 h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
294 ^^^
295]]m4_ifval($2, [[[input.y:20.18-37: warning: unused value: $][3 [-Wmidrule-values]
296 j: INT | INT INT { $<integer>$ = 1; } { $][$ = $][1 + $][2; };
297 ^^^^^^^^^^^^^^^^^^^^
298]]])[[input.y:21.10-68: warning: unset value: $][$ [-Wother]
299 k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
300 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
301input.y:21.10-12: warning: unused value: $][1 [-Wother]
302 k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
303 ^^^
304input.y:21.14-16: warning: unused value: $][2 [-Wother]
305 k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
306 ^^^
307]]m4_ifval($2, [[[input.y:21.35-64: warning: unused value: $][4 [-Wmidrule-values]
308 k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
309 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
310]]]))
311])
312
313## --------------- ##
314## Unused values. ##
315## --------------- ##
316
317AT_SETUP([Unused values])
318AT_CHECK_UNUSED_VALUES
319AT_CHECK_UNUSED_VALUES(, [1])
320AT_CLEANUP
321
322
323## ------------------------------------------ ##
324## Unused values before symbol declarations. ##
325## ------------------------------------------ ##
326
327AT_SETUP([Unused values before symbol declarations])
328AT_CHECK_UNUSED_VALUES([1])
329AT_CHECK_UNUSED_VALUES([1], [1])
330AT_CLEANUP
331
332
333## --------------------------------------------- ##
334## Default %printer and %destructor redeclared. ##
335## --------------------------------------------- ##
336
337AT_SETUP([Default %printer and %destructor redeclared])
338
339# AT_TEST([*])
340# ------------
341m4_pushdef([AT_TEST],
342[AT_DATA([[input.y]],
343[[%destructor { destroy ($$); } <$1> <$1>
344%printer { print ($$); } <$1> <$1>
345
346%destructor { destroy ($$); } <$1>
347%printer { print ($$); } <$1>
348
349%%
350
351start: %empty;
352
353%destructor { destroy ($$); } <$1>;
354%printer { print ($$); } <$1>;
355]])
356
357AT_BISON_CHECK([-fcaret input.y], [1], [],
358[[input.y:1.13-29: error: %destructor redeclaration for <>
359 %destructor { destroy ($$); } <> <>
360 ^^^^^^^^^^^^^^^^^
361input.y:1.13-29: previous declaration
362 %destructor { destroy ($$); } <> <>
363 ^^^^^^^^^^^^^^^^^
364input.y:2.10-24: error: %printer redeclaration for <>
365 %printer { print ($$); } <> <>
366 ^^^^^^^^^^^^^^^
367input.y:2.10-24: previous declaration
368 %printer { print ($$); } <> <>
369 ^^^^^^^^^^^^^^^
370input.y:4.13-29: error: %destructor redeclaration for <>
371 %destructor { destroy ($$); } <>
372 ^^^^^^^^^^^^^^^^^
373input.y:1.13-29: previous declaration
374 %destructor { destroy ($$); } <> <>
375 ^^^^^^^^^^^^^^^^^
376input.y:5.10-24: error: %printer redeclaration for <>
377 %printer { print ($$); } <>
378 ^^^^^^^^^^^^^^^
379input.y:2.10-24: previous declaration
380 %printer { print ($$); } <> <>
381 ^^^^^^^^^^^^^^^
382input.y:11.13-29: error: %destructor redeclaration for <>
383 %destructor { destroy ($$); } <>;
384 ^^^^^^^^^^^^^^^^^
385input.y:1.13-29: previous declaration
386 %destructor { destroy ($$); } <> <>
387 ^^^^^^^^^^^^^^^^^
388input.y:12.10-24: error: %printer redeclaration for <>
389 %printer { print ($$); } <>;
390 ^^^^^^^^^^^^^^^
391input.y:2.10-24: previous declaration
392 %printer { print ($$); } <> <>
393 ^^^^^^^^^^^^^^^
394]])
395])
396
397AT_TEST([], [], [])
398AT_TEST([], [*], [*])
399m4_popdef([AT_TEST])
400
401AT_CLEANUP
402
403
404## ---------------------------------------------- ##
405## Per-type %printer and %destructor redeclared. ##
406## ---------------------------------------------- ##
407
408AT_SETUP([Per-type %printer and %destructor redeclared])
409
410AT_DATA([[input.y]],
411[[%destructor { destroy ($$); } <field1> <field2>
412%printer { print ($$); } <field1> <field2>
413
414%destructor { destroy ($$); } <field1> <field1>
415%printer { print ($$); } <field2> <field2>
416
417%%
418
419start: %empty;
420
421%destructor { destroy ($$); } <field2> <field1>;
422%printer { print ($$); } <field2> <field1>;
423]])
424
425AT_BISON_CHECK([input.y], [1], [],
426[[input.y:4.13-29: error: %destructor redeclaration for <field1>
427input.y:1.13-29: previous declaration
428input.y:4.13-29: error: %destructor redeclaration for <field1>
429input.y:1.13-29: previous declaration
430input.y:5.10-24: error: %printer redeclaration for <field2>
431input.y:2.10-24: previous declaration
432input.y:5.10-24: error: %printer redeclaration for <field2>
433input.y:2.10-24: previous declaration
434input.y:11.13-29: error: %destructor redeclaration for <field2>
435input.y:1.13-29: previous declaration
436input.y:11.13-29: error: %destructor redeclaration for <field1>
437input.y:1.13-29: previous declaration
438input.y:12.10-24: error: %printer redeclaration for <field2>
439input.y:2.10-24: previous declaration
440input.y:12.10-24: error: %printer redeclaration for <field1>
441input.y:2.10-24: previous declaration
442]])
443
444AT_CLEANUP
445
446## ------------------- ##
447## Undefined symbols. ##
448## ------------------- ##
449
450AT_SETUP([Undefined symbols])
451
452AT_DATA([[input.y]],
453[[%printer {} foo baz
454%destructor {} bar
455%type <foo> qux
456%%
457exp: bar;
458]])
459
460AT_BISON_CHECK([-fcaret input.y], [1], [],
461[[input.y:2.16-18: error: symbol bar is used, but is not defined as a token and has no rules
462 %destructor {} bar
463 ^^^
464input.y:1.17-19: warning: symbol baz is used, but is not defined as a token and has no rules [-Wother]
465 %printer {} foo baz
466 ^^^
467input.y:1.13-15: warning: symbol foo is used, but is not defined as a token and has no rules [-Wother]
468 %printer {} foo baz
469 ^^^
470input.y:3.13-15: warning: symbol qux is used, but is not defined as a token and has no rules [-Wother]
471 %type <foo> qux
472 ^^^
473]])
474
475AT_CLEANUP
476
477
478## ----------------------------------------------------- ##
479## Unassociated types used for a printer or destructor. ##
480## ----------------------------------------------------- ##
481
482AT_SETUP([Unassociated types used for a printer or destructor])
483
484AT_DATA([[input.y]],
485[[%token <type1> tag1
486%type <type2> tag2
487
488%printer { } <type1> <type3>
489%destructor { } <type2> <type4>
490
491%%
492
493exp: tag1 { $1; }
494 | tag2 { $1; }
495
496tag2: "a" { $$; }
497]])
498
499AT_BISON_CHECK([input.y], [0], [],
500[[input.y:4.22-28: warning: type <type3> is used, but is not associated to any symbol [-Wother]
501input.y:5.25-31: warning: type <type4> is used, but is not associated to any symbol [-Wother]
502]])
503
504AT_CLEANUP
505
506
507## --------------------------------- ##
508## Useless printers or destructors. ##
509## --------------------------------- ##
510
511AT_SETUP([Useless printers or destructors])
512
513# AT_TEST([INPUT], [STDERR])
514# --------------------------
515m4_pushdef([AT_TEST],
516[AT_DATA([[input.y]],
517[$1
518])
519AT_BISON_CHECK([input.y], [0], [], [$2
520])])
521
522AT_TEST([[%token <type1> token1
523%token <type2> token2
524%token <type3> token3
525%token <type4> token4
526%token <type5> token51 token52
527%token <type6> token61 token62
528%token <type7> token7
529
530%printer {} token1
531%destructor {} token2
532%printer {} token51
533%destructor {} token61
534
535%printer {} token7
536
537%printer {} <type1>
538%destructor {} <type2>
539%printer {} <type3>
540%destructor {} <type4>
541
542%printer {} <type5>
543%destructor {} <type6>
544
545%destructor {} <type7>
546
547%%
548exp: "a";]],
549[[input.y:16.13-19: warning: useless %printer for type <type1> [-Wother]
550input.y:17.16-22: warning: useless %destructor for type <type2> [-Wother]]])
551
552# If everybody is typed, <> is useless.
553AT_TEST([[%type <type> exp
554%token <type> a
555%printer {} <> <*>
556%%
557exp: a;]],
558[[input.y:3.13-14: warning: useless %printer for type <> [-Wother]]])
559
560# If nobody is typed, <*> is useless.
561AT_TEST([[%token a
562%printer {} <> <*>
563%%
564exp: a;]],
565[[input.y:2.16-18: warning: useless %printer for type <*> [-Wother]]])
566
567m4_popdef([AT_TEST])
568
569AT_CLEANUP
570
571
572## ---------------------------------------- ##
573## Unused values with default %destructor. ##
574## ---------------------------------------- ##
575
576AT_SETUP([Unused values with default %destructor])
577
578AT_DATA([[input.y]],
579[[%destructor { destroy ($$); } <>
580%type <tag> tagged
581
582%%
583
584start: end end tagged tagged { $<tag>1; $3; } ;
585end: { } ;
586tagged: { } ;
587]])
588
589AT_BISON_CHECK([-fcaret input.y], [0], [],
590[[input.y:6.8-45: warning: unset value: $$ [-Wother]
591 start: end end tagged tagged { $<tag>1; $3; } ;
592 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
593input.y:6.12-14: warning: unused value: $2 [-Wother]
594 start: end end tagged tagged { $<tag>1; $3; } ;
595 ^^^
596input.y:7.6-8: warning: unset value: $$ [-Wother]
597 end: { } ;
598 ^^^
599]])
600
601AT_DATA([[input.y]],
602[[%destructor { destroy ($$); } <*>
603%type <tag> tagged
604
605%%
606
607start: end end tagged tagged { $<tag>1; $3; } ;
608end: { } ;
609tagged: { } ;
610]])
611
612AT_BISON_CHECK([input.y], [0], [],
613[[input.y:6.23-28: warning: unused value: $4 [-Wother]
614input.y:8.9-11: warning: unset value: $$ [-Wother]
615]])
616
617AT_CLEANUP
618
619
620## ----------------------------------------- ##
621## Unused values with per-type %destructor. ##
622## ----------------------------------------- ##
623
624AT_SETUP([Unused values with per-type %destructor])
625
626AT_DATA([[input.y]],
627[[%destructor { destroy ($$); } <field1>
628%type <field1> start end
629
630%%
631
632start: end end { $1; } ;
633end: { } ;
634]])
635
636AT_BISON_CHECK([-fcaret input.y], [0], [],
637[[input.y:6.8-22: warning: unset value: $$ [-Wother]
638 start: end end { $1; } ;
639 ^^^^^^^^^^^^^^^
640input.y:6.12-14: warning: unused value: $2 [-Wother]
641 start: end end { $1; } ;
642 ^^^
643input.y:7.6-8: warning: unset value: $$ [-Wother]
644 end: { } ;
645 ^^^
646]])
647
648AT_CLEANUP
649
650
651## ---------------------- ##
652## Incompatible Aliases. ##
653## ---------------------- ##
654
655AT_SETUP([Incompatible Aliases])
656
657AT_DATA([input.y],
658[[%token foo "foo"
659
660%type <bar> foo
661%printer {bar} foo
662%destructor {bar} foo
663%left foo
664
665%type <baz> "foo"
666%printer {baz} "foo"
667%destructor {baz} "foo"
668%left "foo"
669
670%%
671exp: foo;
672]])
673
674AT_BISON_CHECK([-fcaret input.y], [1], [],
675[[input.y:8.7-11: error: %type redeclaration for foo
676 %type <baz> "foo"
677 ^^^^^
678input.y:3.7-11: previous declaration
679 %type <bar> foo
680 ^^^^^
681input.y:10.13-17: error: %destructor redeclaration for foo
682 %destructor {baz} "foo"
683 ^^^^^
684input.y:5.13-17: previous declaration
685 %destructor {bar} foo
686 ^^^^^
687input.y:9.10-14: error: %printer redeclaration for foo
688 %printer {baz} "foo"
689 ^^^^^
690input.y:4.10-14: previous declaration
691 %printer {bar} foo
692 ^^^^^
693input.y:11.1-5: error: %left redeclaration for foo
694 %left "foo"
695 ^^^^^
696input.y:6.1-5: previous declaration
697 %left foo
698 ^^^^^
699]])
700
701AT_CLEANUP
702
703
704
705## ----------------------- ##
706## Torturing the Scanner. ##
707## ----------------------- ##
708
709# Be sure to compile and run, so that the C compiler checks what
710# we do.
711
712AT_SETUP([Torturing the Scanner])
713
714AT_BISON_OPTION_PUSHDEFS
715AT_DATA([input.y], [])
716AT_BISON_CHECK([input.y], [1], [],
717[[input.y:1.1: error: syntax error, unexpected end of file
718]])
719
720
721AT_DATA([input.y],
722[{}
723])
724AT_BISON_CHECK([-fcaret input.y], [1], [],
725[[input.y:1.1-2: error: syntax error, unexpected {...}
726 {}
727 ^^
728]])
729
730
731AT_DATA_GRAMMAR([input.y],
732[[%{
733/* This is seen in GCC: a %{ and %} in middle of a comment. */
734const char *foo = "So %{ and %} can be here too.";
735
736#if 0
737/* These examples test Bison while not stressing C compilers too much.
738 Many C compilers mishandle backslash-newlines, so this part of the
739 test is inside "#if 0". The comment and string are written so that
740 the "#endif" will be seen regardless of the C compiler bugs that we
741 know about, namely:
742
743 HP C (as of late 2002) mishandles *\[newline]\[newline]/ within a
744 comment.
745
746 The Apple Darwin compiler (as of late 2002) mishandles
747 \\[newline]' within a character constant.
748
749 */
750
751/\
752* A comment with backslash-newlines in it. %} *\
753\
754/
755/* { Close the above comment, if the C compiler mishandled it. */
756
757char str[] = "\\
758" A string with backslash-newlines in it %{ %} \\
759\
760"";
761
762char apostrophe = '\'';
763#endif
764
765#include <stdio.h>
766#include <stdlib.h>
767#include <assert.h>
768%}
769/* %{ and %} can be here too. */
770
771%{
772/* Exercise pre-prologue dependency to %union. */
773typedef int value;
774%}
775
776/* Exercise M4 quoting: '@:>@@:>@', 0. */
777
778/* Also exercise %union. */
779%union
780{
781 value ival; /* A comment to exercise an old bug. */
782};
783
784
785/* Exercise post-prologue dependency to %union. */
786%{
787static YYSTYPE value_as_yystype (value val);
788
789/* Exercise quotes in declarations. */
790char quote[] = "@:>@@:>@,";
791%}
792
793%{
794]AT_YYERROR_DECLARE[
795]AT_YYLEX_DECLARE[
796%}
797
798%type <ival> '@<:@'
799
800/* Exercise quotes in strings. */
801%token FAKE "fake @<:@@:>@ \a\b\f\n\r\t\v\"\'\?\\\u005B\U0000005c ??!??'??(??)??-??/??<??=??> \x1\1"
802
803%%
804/* Exercise M4 quoting: '@:>@@:>@', @<:@, 1. */
805exp: '@<:@' '\1' two '$' '@' '{' oline output.or.oline.opt
806 {
807 /* Exercise quotes in braces. */
808 char tmp[] = "@<:@%c@:>@,\n";
809 printf (tmp, $1);
810 }
811;
812
813two: '\x000000000000000000000000000000000000000000000000000000000000000000002';
814oline: '@' 'o' 'l' 'i' 'n' 'e' '@' '_' '_' 'o' 'l' 'i' 'n' 'e' '_' '_';
815output.or.oline.opt: %empty;|oline;;|output;;;
816output: '#' 'o' 'u' 't' 'p' 'u' 't' ' ';
817%%
818/* Exercise M4 quoting: '@:>@@:>@', @<:@, 2. */
819
820static YYSTYPE
821value_as_yystype (value val)
822{
823 YYSTYPE res;
824 res.ival = val;
825 return res;
826}
827]AT_YYERROR_DEFINE[
828static int
829yylex (void)
830{
831 static char const input[] = "@<:@\1\2$@{@oline@__@&t@oline__\
832#output "; /* "
833 */
834 static size_t toknum;
835 assert (toknum < sizeof input);
836 yylval = value_as_yystype (input[toknum]);
837 return input[toknum++];
838}
839]])
840
841# Pacify Emacs'font-lock-mode: "
842
843AT_DATA([main.c],
844[[typedef int value;
845#include "input.h"
846
847int yyparse (void);
848]AT_MAIN_DEFINE[
849]])
850AT_BISON_OPTION_POPDEFS
851
852AT_BISON_CHECK([-d -v -o input.c input.y])
853AT_COMPILE([input.o])
854AT_COMPILE([main.o])
855AT_COMPILE([input], [input.o main.o])
856AT_PARSER_CHECK([./input], 0,
857[[[@<:@],
858]])
859
860AT_CLEANUP
861
862
863## ---------------------- ##
864## Typed symbol aliases. ##
865## ---------------------- ##
866
867AT_SETUP([Typed symbol aliases])
868
869# Bison 2.0 broke typed symbol aliases - ensure they work.
870
871AT_DATA_GRAMMAR([input.y],
872[[%union
873{
874 int val;
875};
876%token <val> MY_TOKEN "MY TOKEN"
877%type <val> exp
878%%
879exp: "MY TOKEN";
880%%
881]])
882
883AT_BISON_CHECK([-o input.c input.y])
884
885AT_CLEANUP
886
887
888## --------- ##
889## Require. ##
890## --------- ##
891
892m4_define([AT_CHECK_REQUIRE],
893[AT_SETUP([Require $1])
894AT_DATA_GRAMMAR([input.y],
895[[%require "$1";
896%%
897empty_file: %empty;
898]])
899AT_BISON_CHECK([-o input.c input.y], $2, [], ignore)
900AT_CLEANUP
901])
902
903AT_CHECK_REQUIRE(1.0, 0)
904AT_CHECK_REQUIRE(AT_PACKAGE_VERSION, 0)
905## FIXME: Some day augment this version number.
906AT_CHECK_REQUIRE(100.0, 63)
907
908
909## ------------------------------------- ##
910## String aliases for character tokens. ##
911## ------------------------------------- ##
912
913AT_SETUP([String aliases for character tokens])
914
915# Bison once thought a character token and its alias were different
916# symbols with the same user token number.
917
918AT_DATA_GRAMMAR([input.y],
919[[%token 'a' "a"
920%%
921start: 'a';
922%%
923]])
924
925AT_BISON_CHECK([-o input.c input.y])
926
927AT_CLEANUP
928
929
930## -------------- ##
931## Symbol names. ##
932## -------------- ##
933
934AT_SETUP([Symbols])
935
936AT_BISON_OPTION_PUSHDEFS
937AT_DATA_GRAMMAR([input.y],
938[[%token WITH-DASH
939%token WITHOUT_DASH "WITHOUT-DASH"
940%token WITH.PERIOD
941%token WITHOUT_PERIOD "WITHOUT.PERIOD"
942%code {
943 ]AT_YYERROR_DECLARE[
944 ]AT_YYLEX_DECLARE[
945}
946%%
947start: with-dash without_dash with.period without_period;
948with-dash: WITH-DASH;
949without_dash: "WITHOUT-DASH";
950with.period: WITH.PERIOD;
951without_period: "WITHOUT.PERIOD";
952%%
953]AT_YYERROR_DEFINE[
954]AT_YYLEX_DEFINE[
955]])
956AT_BISON_OPTION_POPDEFS
957
958# POSIX Yacc accept periods, but not dashes.
959AT_BISON_CHECK([--yacc -Wno-error input.y], [], [],
960[[input.y:9.8-16: warning: POSIX Yacc forbids dashes in symbol names: WITH-DASH [-Wyacc]
961input.y:20.8-16: warning: POSIX Yacc forbids dashes in symbol names: with-dash [-Wyacc]
962]])
963
964# So warn about them.
965AT_BISON_CHECK([-Wyacc input.y], [], [],
966[[input.y:9.8-16: warning: POSIX Yacc forbids dashes in symbol names: WITH-DASH [-Wyacc]
967input.y:20.8-16: warning: POSIX Yacc forbids dashes in symbol names: with-dash [-Wyacc]
968]])
969
970# Dashes are fine for GNU Bison.
971AT_BISON_CHECK([-o input.c input.y])
972
973# Make sure we don't export silly token identifiers with periods or dashes.
974AT_COMPILE([input.o])
975
976
977# Periods are genuine letters, they can start identifiers.
978# Digits and dashes cannot.
979AT_DATA_GRAMMAR([input.y],
980[[%token .GOOD
981 -GOOD
982 1NV4L1D
983 -123
984%%
985start: .GOOD GOOD
986]])
987AT_BISON_CHECK([-o input.c input.y], [1], [],
988[[input.y:10.10: error: invalid character: '-'
989input.y:11.10-16: error: invalid identifier: '1NV4L1D'
990input.y:12.10: error: invalid character: '-'
991]])
992
993AT_CLEANUP
994
995
996## ----------------- ##
997## Numbered tokens. ##
998## ----------------- ##
999
1000AT_SETUP([Numbered tokens])
1001
1002AT_DATA_GRAMMAR([redecl.y],
1003[[%token DECIMAL_1 11259375
1004 HEXADECIMAL_1 0xabcdef
1005 HEXADECIMAL_2 0xFEDCBA
1006 DECIMAL_2 16702650
1007%%
1008start: DECIMAL_1 HEXADECIMAL_2;
1009]])
1010
1011AT_BISON_CHECK([redecl.y], [1], [],
1012[[redecl.y:10.10-22: error: user token number 11259375 redeclaration for HEXADECIMAL_1
1013redecl.y:9.8-16: previous declaration for DECIMAL_1
1014redecl.y:12.10-18: error: user token number 16702650 redeclaration for DECIMAL_2
1015redecl.y:11.10-22: previous declaration for HEXADECIMAL_2
1016]])
1017
1018AT_DATA_GRAMMAR([too-large.y],
1019[[%token TOO_LARGE_DEC 999999999999999999999
1020 TOO_LARGE_HEX 0xFFFFFFFFFFFFFFFFFFF
1021%%
1022start: TOO_LARGE_DEC TOO_LARGE_HEX
1023%%
1024]])
1025
1026AT_BISON_CHECK([too-large.y], [1], [],
1027[[too-large.y:9.22-42: error: integer out of range: '999999999999999999999'
1028too-large.y:10.24-44: error: integer out of range: '0xFFFFFFFFFFFFFFFFFFF'
1029]])
1030
1031AT_CLEANUP
1032
1033
1034## --------------------- ##
1035## Unclosed constructs. ##
1036## --------------------- ##
1037
1038AT_SETUP([Unclosed constructs])
1039
1040# Bison's scan-gram.l once forgot to STRING_FINISH some unclosed
1041# constructs, so they were prepended to whatever it STRING_GROW'ed
1042# next. It also threw them away rather than returning them to the
1043# parser. The effect was confusing subsequent error messages.
1044
1045AT_DATA([input.y],
1046[[%token A "a
1047%token B "b"
1048%token AB "ab" // Used to complain that "ab" was already used.
1049%token C '1
1050%token TWO "2"
1051%token TICK_TWELVE "'12" // Used to complain that "'12" was already used.
1052
1053%%
1054
1055start: %empty;
1056
1057// Used to report a syntax error because it didn't see any kind of symbol
1058// identifier.
1059%type <f> 'a
1060;
1061%type <f> "a
1062;
1063// Used to report a syntax error because it didn't see braced code.
1064%destructor { free ($$)
1065]])
1066
1067AT_BISON_CHECK([-fcaret -o input.c input.y], 1, [],
1068[[input.y:1.10-2.0: error: missing '"' at end of line
1069 %token A "a
1070 ^^
1071input.y:4.10-5.0: error: missing "'" at end of line
1072 %token C '1
1073 ^^
1074input.y:14.11-15.0: error: missing "'" at end of line
1075 %type <f> 'a
1076 ^^
1077input.y:16.11-17.0: error: missing '"' at end of line
1078 %type <f> "a
1079 ^^
1080input.y:19.13-20.0: error: missing '}' at end of file
1081 %destructor { free ($$)
1082 ^^^^^^^^^^^
1083input.y:20.1: error: syntax error, unexpected end of file
1084]])
1085
1086AT_CLEANUP
1087
1088
1089## ------------------------- ##
1090## %start after first rule. ##
1091## ------------------------- ##
1092
1093AT_SETUP([%start after first rule])
1094
1095# Bison once complained that a %start after the first rule was a
1096# redeclaration of the start symbol.
1097
1098AT_DATA([input.y],
1099[[%%
1100false_start: %empty;
1101start: false_start ;
1102%start start;
1103]])
1104
1105AT_BISON_CHECK([-o input.c input.y])
1106
1107AT_CLEANUP
1108
1109
1110## --------------------- ##
1111## %prec takes a token. ##
1112## --------------------- ##
1113
1114AT_SETUP([%prec takes a token])
1115
1116# Bison once allowed %prec sym where sym was a nonterminal.
1117
1118AT_DATA([input.y],
1119[[%%
1120start: PREC %prec PREC ;
1121PREC: %empty;
1122]])
1123
1124AT_BISON_CHECK([input.y], [1], [],
1125[[input.y:3.1-4: error: rule given for PREC, which is a token
1126]])
1127
1128AT_CLEANUP
1129
1130
1131## ------------------------------- ##
1132## %prec's token must be defined. ##
1133## ------------------------------- ##
1134
1135AT_SETUP([[%prec's token must be defined]])
1136
1137# According to POSIX, a %prec token must be defined separately.
1138
1139AT_DATA([[input.y]],
1140[[%%
1141start: %prec PREC ;
1142]])
1143
1144AT_BISON_CHECK([[input.y]], [[0]], [],
1145[[input.y:2.8-17: warning: token for %prec is not defined: PREC [-Wother]
1146]])
1147
1148AT_CLEANUP
1149
1150
1151## -------------------------------- ##
1152## Reject unused %code qualifiers. ##
1153## -------------------------------- ##
1154
1155AT_SETUP([Reject unused %code qualifiers])
1156
1157AT_DATA([input-c.y],
1158[[%code q {}
1159%code bad {}
1160%code bad {}
1161%code format {}
1162%%
1163start: %empty;
1164]])
1165AT_BISON_CHECK([[input-c.y]], [[1]], [],
1166[[input-c.y:1.7: error: %code qualifier 'q' is not used
1167input-c.y:2.7-9: error: %code qualifier 'bad' is not used
1168input-c.y:3.7-9: error: %code qualifier 'bad' is not used
1169input-c.y:4.7-12: error: %code qualifier 'format' is not used
1170]])
1171
1172AT_DATA([input-c-glr.y],
1173[[%code q {}
1174%code bad {}
1175 %code bad {}
1176%%
1177start: %empty;
1178]])
1179AT_BISON_CHECK([[input-c-glr.y]], [[1]], [],
1180[[input-c-glr.y:1.7: error: %code qualifier 'q' is not used
1181input-c-glr.y:2.7-9: error: %code qualifier 'bad' is not used
1182input-c-glr.y:3.8-10: error: %code qualifier 'bad' is not used
1183]])
1184
1185AT_DATA([input-c++.y],
1186[[%code q {}
1187%code bad {}
1188 %code q {}
1189%%
1190start: %empty;
1191]])
1192AT_BISON_CHECK([[input-c++.y]], [[1]], [],
1193[[input-c++.y:1.7: error: %code qualifier 'q' is not used
1194input-c++.y:2.7-9: error: %code qualifier 'bad' is not used
1195input-c++.y:3.8: error: %code qualifier 'q' is not used
1196]])
1197
1198AT_DATA([input-c++-glr.y],
1199[[%code bad {}
1200%code q {}
1201%code q {}
1202%%
1203start: %empty;
1204]])
1205AT_BISON_CHECK([[input-c++-glr.y]], [[1]], [],
1206[[input-c++-glr.y:1.7-9: error: %code qualifier 'bad' is not used
1207input-c++-glr.y:2.7: error: %code qualifier 'q' is not used
1208input-c++-glr.y:3.7: error: %code qualifier 'q' is not used
1209]])
1210
1211AT_DATA([special-char-@@.y],
1212[[%code bad {}
1213%code q {}
1214%code q {}
1215%%
1216start: %empty;
1217]])
1218AT_BISON_CHECK([[special-char-@@.y]], [[1]], [],
1219[[special-char-@@.y:1.7-9: error: %code qualifier 'bad' is not used
1220special-char-@@.y:2.7: error: %code qualifier 'q' is not used
1221special-char-@@.y:3.7: error: %code qualifier 'q' is not used
1222]])
1223
1224AT_DATA([special-char-@:>@.y],
1225[[%code bad {}
1226%code q {}
1227%code q {}
1228%%
1229start: %empty;
1230]])
1231AT_BISON_CHECK([[special-char-@:>@.y]], [[1]], [],
1232[[special-char-@:>@.y:1.7-9: error: %code qualifier 'bad' is not used
1233special-char-@:>@.y:2.7: error: %code qualifier 'q' is not used
1234special-char-@:>@.y:3.7: error: %code qualifier 'q' is not used
1235]])
1236
1237AT_CLEANUP
1238
1239
1240## ---------------- ##
1241## Multiple %code. ##
1242## ---------------- ##
1243
1244AT_SETUP([Multiple %code])
1245
1246# Make sure that repeated arguments to %code are separated by
1247# end-of-lines. At some point, a missing eol would leave synclines
1248# appended to the previous value. Here, we use CPP directive to
1249# introduce dependency on the absence/presence of the eol.
1250AT_BISON_OPTION_PUSHDEFS
1251
1252AT_DATA([input.y],
1253[[%code {#include <assert.h>}
1254%code {#define A B}
1255%code {#define B C}
1256%code {#define C D}
1257%code {#define D 42}
1258%code {
1259 ]AT_YYERROR_DECLARE[
1260 ]AT_YYLEX_DECLARE[
1261}
1262%%
1263start: %empty;
1264%%
1265]AT_YYERROR_DEFINE[
1266]AT_YYLEX_DEFINE[
1267int main (void)
1268{
1269 assert (A == 42);
1270 return 0;
1271}
1272]])
1273AT_FULL_COMPILE([input])
1274AT_PARSER_CHECK([./input])
1275
1276AT_BISON_OPTION_POPDEFS
1277AT_CLEANUP()
1278
1279## ---------------- ##
1280## %define errors. ##
1281## ---------------- ##
1282
1283AT_SETUP([%define errors])
1284
1285AT_DATA([input-redefined.y],
1286[[%define var "value1"
1287%define var "value1"
1288 %define var "value2"
1289%define special1 "@:>@"
1290%define special2 "@<:@"
1291%%
1292start: %empty;
1293]])
1294
1295AT_BISON_CHECK([[input-redefined.y]], [[1]], [],
1296[[input-redefined.y:2.9-11: error: %define variable 'var' redefined
1297input-redefined.y:1.9-11: previous definition
1298input-redefined.y:3.10-12: error: %define variable 'var' redefined
1299input-redefined.y:2.9-11: previous definition
1300]])
1301
1302AT_DATA([input-unused.y],
1303[[%define var "value"
1304%%
1305start: %empty;
1306]])
1307
1308AT_BISON_CHECK([[input-unused.y]], [[1]], [],
1309[[input-unused.y:1.9-11: error: %define variable 'var' is not used
1310]])
1311
1312AT_CLEANUP
1313
1314
1315## ----------------------------------- ##
1316## %define, --define, --force-define. ##
1317## ----------------------------------- ##
1318
1319AT_SETUP([[%define, --define, --force-define]])
1320
1321AT_DATA([[skel.c]],
1322[[m4@&t@_divert_push(0)@
1323@output(b4_parser_file_name@)@
1324[var-dd: ]b4_percent_define_get([[var-dd]])[
1325var-ff: ]b4_percent_define_get([[var-ff]])[
1326var-dfg: ]b4_percent_define_get([[var-dfg]])[
1327var-fd: ]b4_percent_define_get([[var-fd]])
1328m4@&t@_divert_pop(0)
1329]])
1330AT_DATA([[input.y]],
1331[[%define var-dfg "gram"
1332%%
1333start: %empty;
1334]])
1335AT_BISON_CHECK([[-Dvar-dd=cmd-d1 -Dvar-dd=cmd-d2 \
1336 -Fvar-ff=cmd-f1 -Fvar-ff=cmd-f2 \
1337 -Dvar-dfg=cmd-d -Fvar-dfg=cmd-f \
1338 -Fvar-fd=cmd-f -Dvar-fd=cmd-d \
1339 --skeleton ./skel.c input.y]])
1340AT_CHECK([[cat input.tab.c]], [[0]],
1341[[var-dd: cmd-d2
1342var-ff: cmd-f2
1343var-dfg: cmd-f
1344var-fd: cmd-d
1345]])
1346
1347AT_DATA([[input-dg.y]],
1348[[%define var "gram"
1349%%
1350start: %empty;
1351]])
1352AT_BISON_CHECK([[-Dvar=cmd-d input-dg.y]], [[1]], [],
1353[[input-dg.y:1.9-11: error: %define variable 'var' redefined
1354<command line>:2: previous definition
1355]])
1356
1357AT_DATA([[input-dg.y]],
1358[[%define var "gram"
1359%%
1360start: %empty;
1361]])
1362AT_BISON_CHECK([[-fcaret -Dvar=cmd-d input-dg.y]], [[1]], [],
1363[[input-dg.y:1.9-11: error: %define variable 'var' redefined
1364 %define var "gram"
1365 ^^^
1366<command line>:3: previous definition
1367]])
1368
1369AT_DATA([[input-unused.y]],
1370[[%%
1371start: %empty;
1372]])
1373AT_BISON_CHECK([[-Dunused-d -Funused-f input-unused.y]], [[1]], [],
1374[[<command line>:2: error: %define variable 'unused-d' is not used
1375<command line>:3: error: %define variable 'unused-f' is not used
1376]])
1377
1378AT_CLEANUP
1379
1380## --------------------------- ##
1381## %define Boolean variables. ##
1382## --------------------------- ##
1383
1384AT_SETUP([["%define" Boolean variables]])
1385
1386AT_DATA([Input.y],
1387[[%language "Java"
1388%define public maybe
1389%define parser_class_name {Input}
1390%%
1391start: %empty;
1392]])
1393
1394AT_BISON_CHECK([[Input.y]], [1], [],
1395[[Input.y:2.9-14: error: invalid value for %define Boolean variable 'public'
1396]])
1397
1398AT_CLEANUP
1399
1400## ------------------------ ##
1401## %define code variables. ##
1402## ------------------------ ##
1403
1404AT_SETUP([["%define" code variables]])
1405
1406m4_pushdef([AT_TEST],
1407[AT_DATA([input.yy],
1408[[%skeleton "lalr1.cc" %locations
1409%define api.location.type ]$1[quux]$2[
1410%define api.namespace ]$1[quux]$2[
1411%define api.prefix ]$1[quux]$2[
1412%define api.token.prefix ]$1[quux]$2[
1413%token TOK // Otherwise api.token.prefix is unused.
1414%%
1415start: TOK;
1416]])
1417
1418AT_BISON_CHECK([[input.yy]], [0], [],
1419[[input.yy:2.9-25: warning: %define variable 'api.location.type' requires '{...}' values [-Wdeprecated]
1420input.yy:4.9-18: warning: %define variable 'api.prefix' requires '{...}' values [-Wdeprecated]
1421input.yy:5.9-24: warning: %define variable 'api.token.prefix' requires '{...}' values [-Wdeprecated]
1422input.yy:3.9-21: warning: %define variable 'api.namespace' requires '{...}' values [-Wdeprecated]
1423]])
1424])
1425
1426AT_TEST([], [])
1427AT_TEST(["], ["])
1428m4_popdef([AT_TEST])
1429
1430AT_CLEANUP
1431
1432
1433## --------------------------- ##
1434## %define keyword variables. ##
1435## --------------------------- ##
1436
1437AT_SETUP([["%define" keyword variables]])
1438
1439m4_pushdef([AT_TEST],
1440[AT_DATA([input.y],
1441[[%define api.pure ]$1[true]$2[
1442%define api.push-pull ]$1[both]$2[
1443%define lr.default-reduction ]$1[most]$2[
1444%define lr.keep-unreachable-state ]$1[true]$2[
1445%define lr.type ]$1[lalr]$2[
1446%%
1447exp: %empty
1448]])
1449
1450AT_BISON_CHECK([[input.y]], [0], [],
1451[[input.y:5.9-15: warning: %define variable 'lr.type' requires keyword values [-Wdeprecated]
1452input.y:3.9-28: warning: %define variable 'lr.default-reduction' requires keyword values [-Wdeprecated]
1453input.y:4.9-33: warning: %define variable 'lr.keep-unreachable-state' requires keyword values [-Wdeprecated]
1454input.y:2.9-21: warning: %define variable 'api.push-pull' requires keyword values [-Wdeprecated]
1455input.y:1.9-16: warning: %define variable 'api.pure' requires keyword values [-Wdeprecated]
1456]])
1457])
1458
1459AT_TEST(["], ["])
1460AT_TEST([{], [}])
1461m4_popdef([AT_TEST])
1462
1463AT_CLEANUP
1464
1465
1466## ------------------------ ##
1467## %define enum variables. ##
1468## ------------------------ ##
1469
1470AT_SETUP([["%define" enum variables]])
1471
1472# Check errors from the front-end, and the back-end. Since the
1473# front-end quits before calling the back-end, these tests cannot be
1474# fused.
1475
1476# Front-end.
1477AT_DATA([[input.y]],
1478[[%define lr.default-reduction bogus
1479%%
1480start: %empty;
1481]])
1482AT_BISON_CHECK([[-fcaret input.y]], [[1]], [[]],
1483[[input.y:1.9-28: error: invalid value for %define variable 'lr.default-reduction': 'bogus'
1484 %define lr.default-reduction bogus
1485 ^^^^^^^^^^^^^^^^^^^^
1486input.y:1.9-28: accepted value: 'most'
1487input.y:1.9-28: accepted value: 'consistent'
1488input.y:1.9-28: accepted value: 'accepting'
1489]])
1490
1491# Back-end.
1492AT_DATA([[input.y]],
1493[[%define api.push-pull neither
1494%%
1495start: %empty;
1496]])
1497AT_BISON_CHECK([[-fcaret input.y]], [[1]], [[]],
1498[[input.y:1.9-21: error: invalid value for %define variable 'api.push-pull': 'neither'
1499 %define api.push-pull neither
1500 ^^^^^^^^^^^^^
1501input.y:1.9-21: accepted value: 'pull'
1502input.y:1.9-21: accepted value: 'push'
1503input.y:1.9-21: accepted value: 'both'
1504]])
1505
1506AT_CLEANUP
1507
1508## -------------------------------- ##
1509## %define backward compatibility. ##
1510## -------------------------------- ##
1511
1512AT_SETUP([["%define" backward compatibility]])
1513
1514# The error messages tell us whether the variables are properly updated.
1515AT_DATA([[input.y]],
1516[[%define api.push_pull both
1517%define lr.keep_unreachable_states maybe
1518%define namespace "foo"
1519%define api.namespace {foo}
1520%define variant
1521%%
1522start: %empty;
1523]])
1524AT_BISON_CHECK([[-fcaret input.y]], [1], [],
1525[[input.y:1.9-21: warning: deprecated directive, use '%define api.push-pull both' [-Wdeprecated]
1526 %define api.push_pull both
1527 ^^^^^^^^^^^^^
1528input.y:2.9-34: warning: deprecated directive, use '%define lr.keep-unreachable-state maybe' [-Wdeprecated]
1529 %define lr.keep_unreachable_states maybe
1530 ^^^^^^^^^^^^^^^^^^^^^^^^^^
1531input.y:3.9-17: warning: deprecated directive, use '%define api.namespace foo' [-Wdeprecated]
1532 %define namespace "foo"
1533 ^^^^^^^^^
1534input.y:4.9-21: error: %define variable 'api.namespace' redefined
1535 %define api.namespace {foo}
1536 ^^^^^^^^^^^^^
1537input.y:3.9-17: previous definition
1538 %define namespace "foo"
1539 ^^^^^^^^^
1540input.y:5.9-15: warning: deprecated directive, use '%define api.value.type variant' [-Wdeprecated]
1541 %define variant
1542 ^^^^^^^
1543]])
1544
1545AT_CLEANUP
1546
1547## ------------------------- ##
1548## Unused %define api.pure. ##
1549## ------------------------- ##
1550
1551AT_SETUP([[Unused %define api.pure]])
1552
1553# AT_CHECK_API_PURE(DECLS, VALUE)
1554# -------------------------------
1555# Make sure Bison reports that '%define api.pure VALUE' is unused when DECLS
1556# are specified.
1557m4_define([AT_CHECK_API_PURE],
1558[
1559AT_DATA([[input.y]],
1560[[%define api.pure ]$2[
1561]$1[
1562%%
1563start: %empty;
1564]])
1565
1566AT_BISON_CHECK([[input.y]], [[1]], [],
1567[[input.y:1.9-16: error: %define variable 'api.pure' is not used
1568]])
1569])
1570
1571AT_CHECK_API_PURE([[%language "c++"]], [[]])
1572AT_CHECK_API_PURE([[%language "c++"]], [[false]])
1573AT_CHECK_API_PURE([[%language "c++" %glr-parser]], [[""]])
1574AT_CHECK_API_PURE([[%language "c++" %glr-parser]], [[false]])
1575AT_CHECK_API_PURE([[%language "java"]], [[true]])
1576AT_CHECK_API_PURE([[%language "java"]], [[false]])
1577
1578AT_CLEANUP
1579
1580## -------------------------------- ##
1581## C++ namespace reference errors. ##
1582## -------------------------------- ##
1583
1584AT_SETUP([[C++ namespace reference errors]])
1585
1586# AT_CHECK_NAMESPACE_ERROR(NAMESPACE-DECL, ERROR, [ERROR], ...)
1587# -------------------------------------------------------------
1588# Make sure Bison reports all ERROR's for %define namespace "NAMESPACE-DECL".
1589m4_define([AT_CHECK_NAMESPACE_ERROR],
1590[
1591AT_DATA([[input.y]],
1592[[%language "C++"
1593%defines
1594%define api.namespace {]$1[}
1595%%
1596start: %empty;
1597]])
1598
1599AT_BISON_CHECK([[input.y]], [1], [],
1600[m4_foreach([b4_arg], m4_dquote(m4_shift($@)),
1601[[input.y:3.9-21: error: ]b4_arg[
1602]])])
1603])
1604
1605AT_CHECK_NAMESPACE_ERROR([[]],
1606 [[namespace reference is empty]])
1607AT_CHECK_NAMESPACE_ERROR([[ @tb@@tb@ @tb@ @tb@]],
1608 [[namespace reference is empty]])
1609AT_CHECK_NAMESPACE_ERROR([[foo::::bar]],
1610 [[namespace reference has consecutive "::"]])
1611AT_CHECK_NAMESPACE_ERROR([[foo:: @tb@::bar]],
1612 [[namespace reference has consecutive "::"]])
1613AT_CHECK_NAMESPACE_ERROR([[::::bar]],
1614 [[namespace reference has consecutive "::"]])
1615AT_CHECK_NAMESPACE_ERROR([[:: ::bar]],
1616 [[namespace reference has consecutive "::"]])
1617AT_CHECK_NAMESPACE_ERROR([[foo::bar::@tb@::]],
1618 [[namespace reference has consecutive "::"]],
1619 [[namespace reference has a trailing "::"]])
1620AT_CHECK_NAMESPACE_ERROR([[foo::bar::]],
1621 [[namespace reference has a trailing "::"]])
1622AT_CHECK_NAMESPACE_ERROR([[foo::bar:: @tb@]],
1623 [[namespace reference has a trailing "::"]])
1624AT_CHECK_NAMESPACE_ERROR([[::]],
1625 [[namespace reference has a trailing "::"]])
1626
1627AT_CLEANUP
1628
1629## ------------------------ ##
1630## Bad character literals. ##
1631## ------------------------ ##
1632
1633# Bison used to accept character literals that were empty or contained
1634# too many characters.
1635
1636# FIXME: AT_DATA or some variant of AT_DATA may eventually permit
1637# the final newline to be omitted. See the threads starting at
1638# <http://lists.gnu.org/archive/html/bison-patches/2009-07/msg00019.html>.
1639
1640AT_SETUP([[Bad character literals]])
1641
1642AT_DATA([empty.y],
1643[[%%
1644start: '';
1645start: '
1646]])
1647AT_CHECK([[$PERL -e "print 'start: \'';" >> empty.y || exit 77]])
1648
1649AT_BISON_CHECK([-fcaret empty.y], [1], [],
1650[[empty.y:2.8-9: warning: empty character literal [-Wother]
1651 start: '';
1652 ^^
1653empty.y:3.8-4.0: error: missing "'" at end of line
1654 start: '
1655 ^
1656empty.y:3.8-4.0: warning: empty character literal [-Wother]
1657 start: '
1658 ^
1659empty.y:4.8: error: missing "'" at end of file
1660 start: '
1661 ^
1662empty.y:4.8: warning: empty character literal [-Wother]
1663 start: '
1664 ^
1665]])
1666
1667AT_DATA([two.y],
1668[[%%
1669start: 'ab';
1670start: 'ab
1671]])
1672AT_CHECK([[$PERL -e "print 'start: \'ab';" >> two.y || exit 77]])
1673
1674AT_BISON_CHECK([two.y], [1], [],
1675[[two.y:2.8-11: warning: extra characters in character literal [-Wother]
1676two.y:3.8-4.0: error: missing "'" at end of line
1677two.y:3.8-4.0: warning: extra characters in character literal [-Wother]
1678two.y:4.8-10: error: missing "'" at end of file
1679two.y:4.8-10: warning: extra characters in character literal [-Wother]
1680]])
1681
1682AT_DATA([three.y],
1683[[%%
1684start: 'abc';
1685start: 'abc
1686]])
1687AT_CHECK([[$PERL -e "print 'start: \'abc';" >> three.y || exit 77]])
1688
1689AT_BISON_CHECK([three.y], [1], [],
1690[[three.y:2.8-12: warning: extra characters in character literal [-Wother]
1691three.y:3.8-4.0: error: missing "'" at end of line
1692three.y:3.8-4.0: warning: extra characters in character literal [-Wother]
1693three.y:4.8-11: error: missing "'" at end of file
1694three.y:4.8-11: warning: extra characters in character literal [-Wother]
1695]])
1696
1697AT_CLEANUP
1698
1699## ------------------------- ##
1700## Bad escapes in literals. ##
1701## ------------------------- ##
1702
1703AT_SETUP([[Bad escapes in literals]])
1704
1705AT_DATA([input.y],
1706[[%%
1707start: '\777' '\0' '\xfff' '\x0'
1708 '\uffff' '\u0000' '\Uffffffff' '\U00000000'
1709 '\ ' '\A';
1710]])
1711
1712# It is not easy to create special characters, we cannot even trust tr.
1713# Beside we cannot even expect "echo '\0'" to output two characters
1714# (well three with \n): at least Bash 3.2 converts the two-character
1715# sequence "\0" into a single NUL character.
1716AT_CHECK([[$PERL -e 'print "start: \"\\\t\\\f\\\0\\\1\" ;";' >> input.y \
1717 || exit 77]])
1718
1719AT_BISON_CHECK([input.y], [1], [],
1720[[input.y:2.9-12: error: invalid number after \-escape: 777
1721input.y:2.8-13: warning: empty character literal [-Wother]
1722input.y:2.16-17: error: invalid number after \-escape: 0
1723input.y:2.15-18: warning: empty character literal [-Wother]
1724input.y:2.21-25: error: invalid number after \-escape: xfff
1725input.y:2.20-26: warning: empty character literal [-Wother]
1726input.y:2.29-31: error: invalid number after \-escape: x0
1727input.y:2.28-32: warning: empty character literal [-Wother]
1728input.y:3.9-14: error: invalid number after \-escape: uffff
1729input.y:3.8-15: warning: empty character literal [-Wother]
1730input.y:3.18-23: error: invalid number after \-escape: u0000
1731input.y:3.17-24: warning: empty character literal [-Wother]
1732input.y:3.27-36: error: invalid number after \-escape: Uffffffff
1733input.y:3.26-37: warning: empty character literal [-Wother]
1734input.y:3.40-49: error: invalid number after \-escape: U00000000
1735input.y:3.39-50: warning: empty character literal [-Wother]
1736input.y:4.9-10: error: invalid character after \-escape: ' '
1737input.y:4.8-11: warning: empty character literal [-Wother]
1738input.y:4.14-15: error: invalid character after \-escape: A
1739input.y:4.13-16: warning: empty character literal [-Wother]
1740input.y:5.9-16: error: invalid character after \-escape: \t
1741input.y:5.17: error: invalid character after \-escape: \f
1742input.y:5.18: error: invalid character after \-escape: \0
1743input.y:5.19: error: invalid character after \-escape: \001
1744]])
1745
1746AT_CLEANUP
1747
1748## ------------------------- ##
1749## LAC: Errors for %define. ##
1750## ------------------------- ##
1751
1752AT_SETUP([[LAC: Errors for %define]])
1753
1754AT_DATA([[input.y]],
1755[[%%
1756start: %empty;
1757]])
1758
1759# parse.lac.* options are useless if LAC isn't actually activated.
1760AT_BISON_CHECK([[-Dparse.lac.es-capacity-initial=1 input.y]],
1761 [[1]], [],
1762[[<command line>:2: error: %define variable 'parse.lac.es-capacity-initial' is not used
1763]])
1764AT_BISON_CHECK([[-Dparse.lac.memory-trace=full input.y]],
1765 [[1]], [],
1766[[<command line>:2: error: %define variable 'parse.lac.memory-trace' is not used
1767]])
1768
1769AT_CLEANUP
1770
1771## --------------------------------------------- ##
1772## -Werror is not affected by -Wnone and -Wall. ##
1773## --------------------------------------------- ##
1774
1775AT_SETUP([[-Werror is not affected by -Wnone and -Wall]])
1776
1777AT_DATA([[input.y]],
1778[[%%
1779a: '0' { $$ = $; };
1780]])
1781
1782# -Werror is not enabled by -Wall or equivalent.
1783AT_BISON_CHECK([[-Wall input.y]], [[0]], [[]],
1784[[input.y:2.15: warning: stray '$' [-Wother]
1785]])
1786AT_BISON_CHECK([[-W input.y]], [[0]], [[]],
1787[[input.y:2.15: warning: stray '$' [-Wother]
1788]])
1789AT_BISON_CHECK([[-Wno-none input.y]], [[0]], [[]],
1790[[input.y:2.15: warning: stray '$' [-Wother]
1791]])
1792
1793# -Werror is not disabled by -Wnone or equivalent.
1794AT_BISON_CHECK([[-Werror,none,other input.y]], [[1]], [[]],
1795[[input.y:2.15: error: stray '$' [-Werror=other]
1796]])
1797AT_BISON_CHECK([[-Werror,no-all,other input.y]], [[1]], [[]],
1798[[input.y:2.15: error: stray '$' [-Werror=other]
1799]])
1800
1801AT_CLEANUP
1802
1803
1804## ------------------------------------------------------ ##
1805## %name-prefix and %define api.prefix are incompatible. ##
1806## ------------------------------------------------------ ##
1807
1808AT_SETUP([[%name-prefix and api.prefix are incompatible]])
1809
1810# AT_TEST(DIRECTIVES, OPTIONS, ERROR-LOCATION)
1811# --------------------------------------------
1812m4_pushdef([AT_TEST],
1813[AT_DATA([[input.y]],
1814[[$1
1815%%
1816exp: %empty;
1817]])
1818AT_BISON_CHECK([[$2 input.y]], [[1]], [[]],
1819[[$3: error: '%name-prefix' and '%define api.prefix' cannot be used together
1820]])
1821])
1822
1823AT_TEST([%define api.prefix {foo} %name-prefix "bar"], [], [input.y:1.9-18])
1824AT_TEST([], [-Dapi.prefix={foo} -p bar], [<command line>:2])
1825AT_TEST([%name-prefix "bar"], [-Dapi.prefix={foo}], [<command line>:2])
1826AT_TEST([%define api.prefix {foo}], [-p bar], [input.y:1.9-18])
1827
1828m4_popdef([AT_TEST])
1829
1830AT_CLEANUP
1831
1832
1833## -------------- ##
1834## Stray $ or @. ##
1835## -------------- ##
1836
1837AT_SETUP([[Stray $ or @]])
1838
1839# Give %printer and %destructor "<*> exp TOK" instead of "<*>" to
1840# check that the warnings are reported once, not three times.
1841
1842AT_DATA_GRAMMAR([[input.y]],
1843[[%type <TYPE> exp
1844%token <TYPE> TOK TOK2
1845%destructor { $%; @%; } <*> exp TOK;
1846%initial-action { $%; @%; };
1847%printer { $%; @%; } <*> exp TOK;
1848%{ $ @ %} // Should not warn.
1849%%
1850exp: TOK { $%; @%; $$ = $1; };
1851%%
1852$ @ // Should not warn.
1853]])
1854
1855AT_BISON_CHECK([[-Wall input.y]], 0, [],
1856[[input.y:11.19: warning: stray '$' [-Wother]
1857input.y:11.23: warning: stray '@' [-Wother]
1858input.y:12.19: warning: stray '$' [-Wother]
1859input.y:12.23: warning: stray '@' [-Wother]
1860input.y:13.19: warning: stray '$' [-Wother]
1861input.y:13.23: warning: stray '@' [-Wother]
1862input.y:16.19: warning: stray '$' [-Wother]
1863input.y:16.23: warning: stray '@' [-Wother]
1864]])
1865
1866AT_CLEANUP
1867
1868
1869
1870## ---------------- ##
1871## Code injection. ##
1872## ---------------- ##
1873
1874
1875AT_SETUP([[Code injection]])
1876
1877m4_pattern_allow([^m4_errprintn$])
1878
1879# AT_TEST([MACRO])
1880# ----------------
1881# Try to have MACRO be run by bison.
1882m4_pushdef([AT_TEST],
1883[AT_DATA([[input.y]],
1884[[%type <$1(DEAD %type)> exp
1885%token <$1(DEAD %token)> a
1886%token b
1887%initial-action
1888{
1889 $$;
1890 $<$1(DEAD %initial-action)>$
1891};
1892%printer
1893{
1894 $$
1895 $<$1(DEAD %printer)>$
1896} <> <*>;
1897%lex-param
1898{
1899 $1(DEAD %lex-param)
1900};
1901%parse-param
1902{
1903 $1(DEAD %parse-param)
1904};
1905%%
1906exp:
1907 a a[name] b
1908 {
1909 $$;
1910 $][1;
1911 $<$1(DEAD action 1)>$
1912 $<$1(DEAD action 2)>1
1913 $<$1(DEAD action 3)>name
1914 $<$1(DEAD action 4)>0
1915 ;
1916 };
1917]])
1918
1919# FIXME: Provide a means to iterate over all the skeletons.
1920AT_BISON_CHECK([[-d input.y]])
1921AT_BISON_CHECK([[-d -S glr.c input.y]])
1922AT_BISON_CHECK([[-d -S lalr1.cc input.y]])
1923AT_BISON_CHECK([[-d -S glr.cc input.y]])
1924AT_BISON_CHECK([[ -S lalr1.java input.y]])
1925])
1926
1927AT_TEST([m4_errprintn])
1928AT_TEST([@:>@m4_errprintn])
1929
1930m4_popdef([AT_TEST])
1931
1932AT_CLEANUP
1933
1934##----------------------- ##
1935## Deprecated directives. ##
1936## ---------------------- ##
1937
1938AT_SETUP([[Deprecated directives]])
1939
1940AT_KEYWORDS([[deprec]])
1941
1942AT_DATA_GRAMMAR([[input.y]],
1943[[
1944%default_prec
1945%error_verbose
1946%expect_rr 0
1947%file-prefix = "foo"
1948%file-prefix
1949 =
1950"bar"
1951%fixed-output_files
1952%fixed_output-files
1953%fixed-output-files
1954%name-prefix= "foo"
1955%no-default_prec
1956%no_default-prec
1957%no_lines
1958%output = "foo"
1959%pure_parser
1960%token_table
1961%glr-parser
1962%% exp : '0'
1963]])
1964
1965AT_BISON_CHECK([[input.y]], [[0]], [[]],
1966[[input.y:10.1-13: warning: deprecated directive: '%default_prec', use '%default-prec' [-Wdeprecated]
1967input.y:11.1-14: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
1968input.y:12.1-10: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
1969input.y:13.1-14: warning: deprecated directive: '%file-prefix =', use '%file-prefix' [-Wdeprecated]
1970input.y:14.1-15.2: warning: deprecated directive: '%file-prefix\n =', use '%file-prefix' [-Wdeprecated]
1971input.y:17.1-19: warning: deprecated directive: '%fixed-output_files', use '%fixed-output-files' [-Wdeprecated]
1972input.y:18.1-19: warning: deprecated directive: '%fixed_output-files', use '%fixed-output-files' [-Wdeprecated]
1973input.y:20.1-13: warning: deprecated directive: '%name-prefix=', use '%name-prefix' [-Wdeprecated]
1974input.y:21.1-16: warning: deprecated directive: '%no-default_prec', use '%no-default-prec' [-Wdeprecated]
1975input.y:22.1-16: warning: deprecated directive: '%no_default-prec', use '%no-default-prec' [-Wdeprecated]
1976input.y:23.1-9: warning: deprecated directive: '%no_lines', use '%no-lines' [-Wdeprecated]
1977input.y:24.1-9: warning: deprecated directive: '%output =', use '%output' [-Wdeprecated]
1978input.y:25.1-12: warning: deprecated directive: '%pure_parser', use '%pure-parser' [-Wdeprecated]
1979input.y:26.1-12: warning: deprecated directive: '%token_table', use '%token-table' [-Wdeprecated]
1980]])
1981
1982AT_CLEANUP
1983
1984## ---------------------------- ##
1985## Unput's effect on locations. ##
1986## ---------------------------- ##
1987dnl When the scanner detects a deprecated construct, it unputs the correct
1988dnl version, but it should *not* have any impact on the scanner cursor. If it
1989dnl does, the locations of directives on the same line become erroneous.
1990
1991AT_SETUP([[Unput's effect on locations]])
1992
1993AT_KEYWORDS([[deprec]])
1994
1995AT_DATA_GRAMMAR([[input.y]],
1996[[
1997%glr-parser
1998%expect_rr 42 %expect_rr 42
1999 %expect_rr 42
2000%error_verbose %error_verbose
2001 %error_verbose
2002%% exp: '0'
2003]])
2004
2005AT_BISON_CHECK([[input.y]], [[1]], [[]],
2006[[input.y:11.1-10: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
2007input.y:11.15-24: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
2008input.y:12.15-24: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
2009input.y:13.1-14: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
2010input.y:13.16-29: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
2011input.y:13.11-21: error: %define variable 'parse.error' redefined
2012input.y:13-6: previous definition
2013input.y:14.16-29: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
2014input.y:14.11-21: error: %define variable 'parse.error' redefined
2015input.y:13.11-21: previous definition
2016]])
2017
2018AT_CLEANUP
2019
2020##--------------------------- ##
2021## Non-deprecated directives. ##
2022## -------------------------- ##
2023
2024AT_SETUP([[Non-deprecated directives]])
2025
2026AT_KEYWORDS([[deprec]])
2027
2028AT_DATA_GRAMMAR([[input.y]],
2029[[
2030%default-prec
2031%error-verbose
2032%expect-rr 42
2033%file-prefix "foo"
2034%file-prefix
2035"bar"
2036%fixed-output-files
2037%name-prefix "foo"
2038%no-default-prec
2039%no-lines
2040%output "foo"
2041%pure-parser
2042%token-table
2043%% exp : '0'
2044]])
2045
2046AT_BISON_CHECK([[input.y]], [[0]], [[]],
2047[[input.y: warning: %expect-rr applies only to GLR parsers [-Wother]
2048]])
2049
2050AT_CLEANUP