]> git.saurik.com Git - bison.git/blame - tests/input.at
Merge branch 'maint'
[bison.git] / tests / input.at
CommitLineData
087b9fdf 1# Checking the Bison scanner. -*- Autotest -*-
7d424de1 2
34136e65 3# Copyright (C) 2002-2012 Free Software Foundation, Inc.
9b2d0677 4
f16b0819 5# This program is free software: you can redistribute it and/or modify
9b2d0677 6# it under the terms of the GNU General Public License as published by
f16b0819
PE
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
9b2d0677
AD
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.
f16b0819 14#
9b2d0677 15# You should have received a copy of the GNU General Public License
f16b0819 16# along with this program. If not, see <http://www.gnu.org/licenses/>.
9b2d0677
AD
17
18AT_BANNER([[Input Processing.]])
19
20# Mostly test that we are robust to mistakes.
21
6c35d22c 22
baf0bd61
AD
23## ---------------- ##
24## Invalid inputs. ##
25## ---------------- ##
26
27AT_SETUP([Invalid inputs])
28
29AT_DATA([input.y],
95066e92
AD
30[[\000\001\002\377?
31%%
baf0bd61
AD
32?
33default: 'a' }
34%&
35%a-does-not-exist
36%-
37%{
38]])
95066e92 39AT_CHECK([[$PERL -pi -e 's/\\(\d{3})/chr(oct($1))/ge' input.y || exit 77]])
baf0bd61
AD
40
41AT_BISON_CHECK([input.y], [1], [],
04901623
AD
42[[input.y:1.1: error: invalid character: '\0'
43input.y:1.1: error: invalid character: '\001'
44input.y:1.1: error: invalid character: '\002'
45input.y:1.1: error: invalid character: '\377'
46input.y:1.2: error: invalid character: '?'
47input.y:3.1: error: invalid character: '?'
48input.y:4.14: error: invalid character: '}'
49input.y:5.1: error: invalid character: '%'
50input.y:5.2: error: invalid character: '&'
51input.y:6.1-17: error: invalid directive: '%a-does-not-exist'
52input.y:7.1: error: invalid character: '%'
53input.y:7.2: error: invalid character: '-'
54input.y:8.1-9.0: error: missing '%}' at end of file
55input.y:8.1-9.0: error: syntax error, unexpected %{...%}
baf0bd61
AD
56]])
57
58AT_CLEANUP
59
60
61AT_SETUP([Invalid inputs with {}])
62
63# We used to SEGV here. See
64# http://lists.gnu.org/archive/html/bug-bison/2005-07/msg00053.html
65
66AT_DATA([input.y],
67[[
68%destructor
69%initial-action
70%lex-param
71%parse-param
72%printer
73%union
74]])
75
76AT_BISON_CHECK([input.y], [1], [],
04901623 77[[input.y:3.1-15: error: syntax error, unexpected %initial-action, expecting {...}
baf0bd61
AD
78]])
79
80AT_CLEANUP
81
82
83
9b2d0677
AD
84## ------------ ##
85## Invalid $n. ##
86## ------------ ##
87
287b314e 88AT_SETUP([Invalid $n and @n])
9b2d0677
AD
89
90AT_DATA([input.y],
91[[%%
bfcf1f3a 92exp: { $$ = $1 ; };
bfcf1f3a 93exp: { @$ = @1 ; };
9b2d0677
AD
94]])
95
da730230 96AT_BISON_CHECK([input.y], [1], [],
b8e7ad58
TR
97[[input.y:2.13-14: error: integer out of range: '$1'
98input.y:3.13-14: error: integer out of range: '@1'
9b2d0677
AD
99]])
100
101AT_CLEANUP
9af3fbce
AD
102
103
104## -------------- ##
e776192e 105## Type Clashes. ##
9af3fbce
AD
106## -------------- ##
107
e776192e 108AT_SETUP([Type Clashes])
9af3fbce
AD
109
110AT_DATA([input.y],
ffa4ba3a
JD
111[[%union { int bar; }
112%token foo
9af3fbce
AD
113%type <bar> exp
114%%
ffa4ba3a 115exp: foo { $$; } foo { $2; } foo
9af3fbce
AD
116 | foo
117 | /* Empty. */
118 ;
119]])
120
da730230 121AT_BISON_CHECK([input.y], [1], [],
b8e7ad58
TR
122[[input.y:5.12-13: error: $$ for the midrule at $2 of 'exp' has no declared type
123input.y:5.24-25: error: $2 of 'exp' has no declared type
73370a9d
VS
124input.y:5.6-32: warning: type clash on default action: <bar> != <> [-Wother]
125input.y:6.6-8: warning: type clash on default action: <bar> != <> [-Wother]
126input.y:7.5: warning: empty rule for typed nonterminal, and no action [-Wother]
9af3fbce
AD
127]])
128
129AT_CLEANUP
5a08f1ce
AD
130
131
ffa4ba3a 132# _AT_UNUSED_VALUES_DECLARATIONS()
dab244d5 133# --------------------------------
ffa4ba3a
JD
134# Generate the token, type, and destructor
135# declarations for the unused values tests.
ffa4ba3a
JD
136m4_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;]]])
378f4bd8 140
ffa4ba3a 141
17bd8a73 142# AT_CHECK_UNUSED_VALUES(DECLARATIONS_AFTER, CHECK_MIDRULE_VALUES)
dab244d5
AD
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.
ffa4ba3a
JD
148m4_define([AT_CHECK_UNUSED_VALUES],
149[AT_DATA([input.y],
150m4_ifval($1, [
151
152
153], [_AT_UNUSED_VALUES_DECLARATIONS
154])[[%%
27622431 155start:
e8cd1ad6
DJ
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[; }
378f4bd8 159;
27622431
PE
160
161a: INT | INT { } INT { } INT { };
162b: INT | /* empty */;
e8cd1ad6
DJ
163c: INT | INT { $]1[; } INT { $<integer>2; } INT { $<integer>4; };
164d: INT | INT { } INT { $]1[; } INT { $<integer>2; };
165e: INT | INT { } INT { } INT { $]1[; };
ffa4ba3a 166f: INT | INT { } INT { } INT { $]$[ = $]1[ + $]3[ + $]5[; };
ddc8ede1
PE
167g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
168h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
ffa4ba3a
JD
169i: INT | INT INT { } { $]$[ = $]1[ + $]2[; };
170j: INT | INT INT { $<integer>$ = 1; } { $]$[ = $]1[ + $]2[; };
ddc8ede1
PE
171k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
172l: INT | INT { $<integer>$ = $<integer>1; } INT { $<integer>$ = $<integer>2 + $<integer>3; } INT { $<integer>$ = $<integer>4 + $<integer>5; };]]m4_ifval($1, [
ffa4ba3a
JD
173_AT_UNUSED_VALUES_DECLARATIONS])
174)
175
da730230 176AT_BISON_CHECK(m4_ifval($2, [ --warnings=midrule-values ])[ input.y], [0], [],
73370a9d
VS
177[[input.y:11.10-32: warning: unset value: $]$[ [-Wother]
178input.y:11.10-32: warning: unused value: $]1[ [-Wother]
179input.y:11.10-32: warning: unused value: $]3[ [-Wother]
180input.y:11.10-32: warning: unused value: $]5[ [-Wother]
181input.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]
183input.y:13.26-41: warning: unset value: $$ [-Wmidrule-values]
184]]])[[input.y:13.10-62: warning: unset value: $]$[ [-Wother]
185input.y:13.10-62: warning: unused value: $]3[ [-Wother]
186input.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]
189input.y:14.10-49: warning: unused value: $]3[ [-Wother]
190input.y:14.10-49: warning: unused value: $]5[ [-Wother]
191input.y:15.10-37: warning: unset value: $]$[ [-Wother]
192input.y:15.10-37: warning: unused value: $]3[ [-Wother]
193input.y:15.10-37: warning: unused value: $]5[ [-Wother]
194input.y:17.10-58: warning: unset value: $]$[ [-Wother]
195input.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]
200input.y:18.10-72: warning: unset value: $]$[ [-Wother]
201input.y:18.10-72: warning: unused value: $]1[ [-Wother]
202input.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]
207input.y:21.10-68: warning: unused value: $]1[ [-Wother]
208input.y:21.10-68: warning: unused value: $]2[ [-Wother]
209]]m4_ifval($2, [[[input.y:21.10-68: warning: unused value: $]4[ [-Wmidrule-values]
17bd8a73 210]]]))])
27622431 211
378f4bd8 212
ffa4ba3a
JD
213## --------------- ##
214## Unused values. ##
215## --------------- ##
216
217AT_SETUP([Unused values])
218AT_CHECK_UNUSED_VALUES
17bd8a73 219AT_CHECK_UNUSED_VALUES(, [1])
ffa4ba3a
JD
220AT_CLEANUP
221
222
223## ------------------------------------------ ##
224## Unused values before symbol declarations. ##
225## ------------------------------------------ ##
84866159 226
ffa4ba3a
JD
227AT_SETUP([Unused values before symbol declarations])
228AT_CHECK_UNUSED_VALUES([1])
17bd8a73 229AT_CHECK_UNUSED_VALUES([1], [1])
84866159 230AT_CLEANUP
378f4bd8
AD
231
232
ec5479ce
JD
233## --------------------------------------------- ##
234## Default %printer and %destructor redeclared. ##
235## --------------------------------------------- ##
236
237AT_SETUP([Default %printer and %destructor redeclared])
238
239AT_DATA([[input.y]],
12e35840 240[[%destructor { destroy ($$); } <*> <*>
abcd36ca 241%printer { print ($$); } <*> <*>
ec5479ce 242
12e35840 243%destructor { destroy ($$); } <*>
abcd36ca 244%printer { print ($$); } <*>
12e35840 245
3ebecc24 246%destructor { destroy ($$); } <> <>
abcd36ca 247%printer { print ($$); } <> <>
12e35840 248
3ebecc24 249%destructor { destroy ($$); } <>
abcd36ca 250%printer { print ($$); } <>
ec5479ce
JD
251
252%%
253
254start: ;
255
12e35840 256%destructor { destroy ($$); } <*>;
abcd36ca 257%printer { print ($$); } <*>;
12e35840 258
3ebecc24 259%destructor { destroy ($$); } <>;
abcd36ca 260%printer { print ($$); } <>;
ec5479ce
JD
261]])
262
da730230 263AT_BISON_CHECK([input.y], [1], [],
11b19212 264[[input.y:1.13-29: error: %destructor redeclaration for <*>
cbaea010 265input.y:1.13-29: previous declaration
11b19212 266input.y:2.10-24: error: %printer redeclaration for <*>
cbaea010 267input.y:2.10-24: previous declaration
11b19212 268input.y:4.13-29: error: %destructor redeclaration for <*>
cbaea010 269input.y:1.13-29: previous declaration
11b19212 270input.y:5.10-24: error: %printer redeclaration for <*>
cbaea010 271input.y:2.10-24: previous declaration
11b19212 272input.y:7.13-29: error: %destructor redeclaration for <>
cbaea010 273input.y:7.13-29: previous declaration
11b19212 274input.y:8.10-24: error: %printer redeclaration for <>
cbaea010 275input.y:8.10-24: previous declaration
11b19212 276input.y:10.13-29: error: %destructor redeclaration for <>
cbaea010 277input.y:7.13-29: previous declaration
11b19212 278input.y:11.10-24: error: %printer redeclaration for <>
cbaea010 279input.y:8.10-24: previous declaration
11b19212 280input.y:17.13-29: error: %destructor redeclaration for <*>
cbaea010 281input.y:4.13-29: previous declaration
11b19212 282input.y:18.10-24: error: %printer redeclaration for <*>
cbaea010 283input.y:5.10-24: previous declaration
11b19212 284input.y:20.13-29: error: %destructor redeclaration for <>
cbaea010 285input.y:10.13-29: previous declaration
11b19212 286input.y:21.10-24: error: %printer redeclaration for <>
cbaea010 287input.y:11.10-24: previous declaration
ec5479ce
JD
288]])
289
290AT_CLEANUP
291
292
b2a0b7ca
JD
293## ---------------------------------------------- ##
294## Per-type %printer and %destructor redeclared. ##
295## ---------------------------------------------- ##
296
297AT_SETUP([Per-type %printer and %destructor redeclared])
298
299AT_DATA([[input.y]],
300[[%destructor { destroy ($$); } <field1> <field2>
abcd36ca 301%printer { print ($$); } <field1> <field2>
b2a0b7ca
JD
302
303%destructor { destroy ($$); } <field1> <field1>
abcd36ca 304%printer { print ($$); } <field2> <field2>
b2a0b7ca
JD
305
306%%
307
308start: ;
309
310%destructor { destroy ($$); } <field2> <field1>;
abcd36ca 311%printer { print ($$); } <field2> <field1>;
b2a0b7ca
JD
312]])
313
da730230 314AT_BISON_CHECK([input.y], [1], [],
b8e7ad58 315[[input.y:4.13-29: error: %destructor redeclaration for <field1>
cbaea010 316input.y:1.13-29: previous declaration
b8e7ad58 317input.y:4.13-29: error: %destructor redeclaration for <field1>
cbaea010 318input.y:4.13-29: previous declaration
b8e7ad58 319input.y:5.10-24: error: %printer redeclaration for <field2>
cbaea010 320input.y:2.10-24: previous declaration
b8e7ad58 321input.y:5.10-24: error: %printer redeclaration for <field2>
cbaea010 322input.y:5.10-24: previous declaration
b8e7ad58 323input.y:11.13-29: error: %destructor redeclaration for <field1>
cbaea010 324input.y:4.13-29: previous declaration
b8e7ad58 325input.y:11.13-29: error: %destructor redeclaration for <field2>
cbaea010 326input.y:1.13-29: previous declaration
b8e7ad58 327input.y:12.10-24: error: %printer redeclaration for <field1>
cbaea010 328input.y:2.10-24: previous declaration
b8e7ad58 329input.y:12.10-24: error: %printer redeclaration for <field2>
cbaea010 330input.y:5.10-24: previous declaration
b2a0b7ca
JD
331]])
332
333AT_CLEANUP
334
31557b9e
AD
335## ------------------- ##
336## Undefined symbols. ##
337## ------------------- ##
b921d92f 338
31557b9e 339AT_SETUP([Undefined symbols])
b921d92f
VS
340
341AT_DATA([[input.y]],
3b0b682f
AD
342[[%printer {} foo baz
343%destructor {} bar
31557b9e 344%type <foo> qux
b921d92f 345%%
3b0b682f 346exp: bar;
b921d92f
VS
347]])
348
3b0b682f 349AT_BISON_CHECK([input.y], [1], [],
11b19212 350[[input.y:2.16-18: error: symbol bar is used, but is not defined as a token and has no rules
73370a9d
VS
351input.y:1.17-19: warning: symbol baz is used, but is not defined as a token and has no rules [-Wother]
352input.y:1.13-15: warning: symbol foo is used, but is not defined as a token and has no rules [-Wother]
31557b9e 353input.y:3.13-15: warning: symbol qux is used, but is not defined as a token and has no rules [-Wother]
b921d92f
VS
354]])
355
356AT_CLEANUP
357
b2a0b7ca 358
9641b918
VS
359## ----------------------------------------------------- ##
360## Unassociated types used for a printer or destructor. ##
361## ----------------------------------------------------- ##
362
363AT_SETUP([Unassociated types used for a printer or destructor])
364
365AT_DATA([[input.y]],
366[[%token <type1> tag1
367%type <type2> tag2
368
369%printer { } <type1> <type3>
370%destructor { } <type2> <type4>
371
372%%
373
374exp: tag1 { $1; }
375 | tag2 { $1; }
376
377tag2: "a" { $$; }
378]])
379
380AT_BISON_CHECK([input.y], [0], [],
73370a9d
VS
381[[input.y:4.22-28: warning: type <type3> is used, but is not associated to any symbol [-Wother]
382input.y:5.25-31: warning: type <type4> is used, but is not associated to any symbol [-Wother]
9641b918
VS
383]])
384
385AT_CLEANUP
386
387
ea9a35c6
VS
388## --------------------------------- ##
389## Useless printers or destructors. ##
390## --------------------------------- ##
391
392AT_SETUP([Useless printers or destructors])
393
9534d2be
AD
394# AT_TEST([INPUT], [STDERR])
395# --------------------------
396m4_pushdef([AT_TEST],
397[AT_DATA([[input.y]],
398[$1
399])
400AT_BISON_CHECK([input.y], [0], [], [$2
401])])
402
403AT_TEST([[%token <type1> token1
ea9a35c6
VS
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
410
411%printer {} token1
412%destructor {} token2
413%printer {} token51
414%destructor {} token61
415
416%printer {} token7
417
418%printer {} <type1>
419%destructor {} <type2>
420%printer {} <type3>
421%destructor {} <type4>
422
423%printer {} <type5>
424%destructor {} <type6>
425
426%destructor {} <type7>
427
428%%
9534d2be 429exp: "a";]],
73370a9d 430[[input.y:16.13-19: warning: useless %printer for type <type1> [-Wother]
9534d2be
AD
431input.y:17.16-22: warning: useless %destructor for type <type2> [-Wother]]])
432
433# If everybody is typed, <> is useless.
434AT_TEST([[%type <type> exp
435%token <type> a
436%printer {} <> <*>
437%%
438exp: a;]],
439[[input.y:3.13-14: warning: useless %printer for type <> [-Wother]]])
440
84271837 441# If nobody is typed, <*> is useless.
9534d2be
AD
442AT_TEST([[%token a
443%printer {} <> <*>
444%%
445exp: a;]],
446[[input.y:2.16-18: warning: useless %printer for type <*> [-Wother]]])
ea9a35c6 447
9534d2be 448m4_popdef([AT_TEST])
ea9a35c6
VS
449
450AT_CLEANUP
451
452
ec5479ce
JD
453## ---------------------------------------- ##
454## Unused values with default %destructor. ##
455## ---------------------------------------- ##
456
457AT_SETUP([Unused values with default %destructor])
458
459AT_DATA([[input.y]],
3ebecc24 460[[%destructor { destroy ($$); } <>
12e35840
JD
461%type <tag> tagged
462
463%%
464
465start: end end tagged tagged { $<tag>1; $3; } ;
466end: { } ;
467tagged: { } ;
468]])
469
da730230 470AT_BISON_CHECK([input.y], [0], [],
73370a9d
VS
471[[input.y:6.8-45: warning: unset value: $$ [-Wother]
472input.y:6.8-45: warning: unused value: $2 [-Wother]
473input.y:7.6-8: warning: unset value: $$ [-Wother]
12e35840
JD
474]])
475
476AT_DATA([[input.y]],
477[[%destructor { destroy ($$); } <*>
478%type <tag> tagged
ec5479ce
JD
479
480%%
481
12e35840
JD
482start: end end tagged tagged { $<tag>1; $3; } ;
483end: { } ;
484tagged: { } ;
ec5479ce
JD
485]])
486
da730230 487AT_BISON_CHECK([input.y], [0], [],
73370a9d
VS
488[[input.y:6.8-45: warning: unused value: $4 [-Wother]
489input.y:8.9-11: warning: unset value: $$ [-Wother]
ec5479ce
JD
490]])
491
492AT_CLEANUP
493
494
b2a0b7ca
JD
495## ----------------------------------------- ##
496## Unused values with per-type %destructor. ##
497## ----------------------------------------- ##
498
499AT_SETUP([Unused values with per-type %destructor])
500
501AT_DATA([[input.y]],
502[[%destructor { destroy ($$); } <field1>
503%type <field1> start end
504
505%%
506
507start: end end { $1; } ;
508end: { } ;
509]])
510
da730230 511AT_BISON_CHECK([input.y], [0], [],
73370a9d
VS
512[[input.y:6.8-22: warning: unset value: $$ [-Wother]
513input.y:6.8-22: warning: unused value: $2 [-Wother]
514input.y:7.6-8: warning: unset value: $$ [-Wother]
b2a0b7ca
JD
515]])
516
517AT_CLEANUP
518
519
df09ef2e
AD
520## ---------------------- ##
521## Incompatible Aliases. ##
522## ---------------------- ##
523
524AT_SETUP([Incompatible Aliases])
525
526AT_DATA([input.y],
527[[%token foo "foo"
528
529%type <bar> foo
530%printer {bar} foo
531%destructor {bar} foo
532%left foo
533
534%type <baz> "foo"
535%printer {baz} "foo"
536%destructor {baz} "foo"
537%left "foo"
538
539%%
540exp: foo;
541]])
542
da730230 543AT_BISON_CHECK([input.y], [1], [],
b8e7ad58 544[[input.y:8.7-11: error: %type redeclaration for foo
cbaea010 545input.y:3.7-11: previous declaration
b8e7ad58 546input.y:10.13-17: error: %destructor redeclaration for foo
cbaea010 547input.y:5.13-17: previous declaration
b8e7ad58 548input.y:9.10-14: error: %printer redeclaration for foo
cbaea010 549input.y:4.10-14: previous declaration
b8e7ad58 550input.y:11.1-5: error: %left redeclaration for foo
cbaea010 551input.y:6.1-5: previous declaration
df09ef2e
AD
552]])
553
554AT_CLEANUP
555
556
5a08f1ce
AD
557
558## ----------------------- ##
559## Torturing the Scanner. ##
560## ----------------------- ##
561
562# Be sure to compile and run, so that the C compiler checks what
563# we do.
564
565AT_SETUP([Torturing the Scanner])
566
71c7e24f 567AT_BISON_OPTION_PUSHDEFS
0baf7c50 568AT_DATA([input.y], [])
da730230 569AT_BISON_CHECK([input.y], [1], [],
b8e7ad58 570[[input.y:1.1: error: syntax error, unexpected end of file
0baf7c50
PE
571]])
572
573
e9071366 574AT_DATA([input.y],
b2ddc3f3
AD
575[{}
576])
da730230 577AT_BISON_CHECK([input.y], [1], [],
b8e7ad58 578[[input.y:1.1-2: error: syntax error, unexpected {...}
b2ddc3f3
AD
579]])
580
581
9501dc6e 582AT_DATA_GRAMMAR([input.y],
5a08f1ce
AD
583[[%{
584/* This is seen in GCC: a %{ and %} in middle of a comment. */
585const char *foo = "So %{ and %} can be here too.";
586
dda7a53e
PE
587#if 0
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
592 know about, namely:
593
594 HP C (as of late 2002) mishandles *\[newline]\[newline]/ within a
595 comment.
596
597 The Apple Darwin compiler (as of late 2002) mishandles
598 \\[newline]' within a character constant.
599
600 */
601
206fe6a5 602/\
dda7a53e
PE
603* A comment with backslash-newlines in it. %} *\
604\
206fe6a5 605/
dda7a53e 606/* { Close the above comment, if the C compiler mishandled it. */
206fe6a5
PE
607
608char str[] = "\\
609" A string with backslash-newlines in it %{ %} \\
dda7a53e 610\
206fe6a5
PE
611"";
612
dda7a53e 613char apostrophe = '\'';
206fe6a5
PE
614#endif
615
5a08f1ce 616#include <stdio.h>
c4bd5bf7 617#include <stdlib.h>
77519a7d 618#include <assert.h>
5a08f1ce
AD
619%}
620/* %{ and %} can be here too. */
621
622%{
623/* Exercise pre-prologue dependency to %union. */
051ade83 624typedef int value;
5a08f1ce
AD
625%}
626
627/* Exercise M4 quoting: '@:>@@:>@', 0. */
628
629/* Also exercise %union. */
630%union
631{
051ade83 632 value ival; /* A comment to exercise an old bug. */
5a08f1ce
AD
633};
634
635
636/* Exercise post-prologue dependency to %union. */
637%{
051ade83 638static YYSTYPE value_as_yystype (value val);
5a08f1ce
AD
639
640/* Exercise quotes in declarations. */
641char quote[] = "@:>@@:>@,";
642%}
643
644%{
55f48c48
AD
645]AT_YYERROR_DECLARE[
646]AT_YYLEX_DECLARE[
5a08f1ce
AD
647%}
648
206fe6a5 649%type <ival> '@<:@'
5a08f1ce
AD
650
651/* Exercise quotes in strings. */
3dc4c5fa 652%token FAKE "fake @<:@@:>@ \a\b\f\n\r\t\v\"\'\?\\\u005B\U0000005c ??!??'??(??)??-??/??<??=??> \x1\1"
5a08f1ce
AD
653
654%%
206fe6a5 655/* Exercise M4 quoting: '@:>@@:>@', @<:@, 1. */
087b9fdf 656exp: '@<:@' '\1' two '$' '@' '{' oline output.or.oline.opt
5a08f1ce
AD
657 {
658 /* Exercise quotes in braces. */
659 char tmp[] = "@<:@%c@:>@,\n";
660 printf (tmp, $1);
661 }
662;
5b7f88c7
PE
663
664two: '\x000000000000000000000000000000000000000000000000000000000000000000002';
665oline: '@' 'o' 'l' 'i' 'n' 'e' '@' '_' '_' 'o' 'l' 'i' 'n' 'e' '_' '_';
087b9fdf 666output.or.oline.opt: ;|oline;;|output;;;
5b7f88c7 667output: '#' 'o' 'u' 't' 'p' 'u' 't' ' ';
5a08f1ce 668%%
206fe6a5 669/* Exercise M4 quoting: '@:>@@:>@', @<:@, 2. */
5a08f1ce
AD
670
671static YYSTYPE
051ade83 672value_as_yystype (value val)
5a08f1ce
AD
673{
674 YYSTYPE res;
675 res.ival = val;
676 return res;
677}
71c7e24f 678]AT_YYERROR_DEFINE[
7172e23e 679static int
5a08f1ce
AD
680yylex (void)
681{
cf806753 682 static char const input[] = "@<:@\1\2$@{@oline@__@&t@oline__\
5b7f88c7
PE
683#output "; /* "
684 */
cf806753 685 static size_t toknum;
77519a7d 686 assert (toknum < sizeof input);
cf806753
PE
687 yylval = value_as_yystype (input[toknum]);
688 return input[toknum++];
5a08f1ce 689}
5a08f1ce
AD
690]])
691
9501dc6e
AD
692# Pacify Emacs'font-lock-mode: "
693
5a08f1ce 694AT_DATA([main.c],
051ade83 695[[typedef int value;
5a08f1ce
AD
696#include "input.h"
697
698int yyparse (void);
699
700int
701main (void)
702{
703 return yyparse ();
704}
705]])
71c7e24f 706AT_BISON_OPTION_POPDEFS
5a08f1ce 707
da730230 708AT_BISON_CHECK([-d -v -o input.c input.y])
91ce0b3a
AD
709AT_COMPILE([input.o])
710AT_COMPILE([main.o])
efc6bf1b 711AT_COMPILE([input], [input.o main.o])
1154cced 712AT_PARSER_CHECK([./input], 0,
206fe6a5 713[[[@<:@],
5a08f1ce
AD
714]])
715
716AT_CLEANUP
e59adf8f
PE
717
718
719## ---------------------- ##
720## Typed symbol aliases. ##
721## ---------------------- ##
722
723AT_SETUP([Typed symbol aliases])
724
725# Bison 2.0 broke typed symbol aliases - ensure they work.
726
727AT_DATA_GRAMMAR([input.y],
728[[%union
729{
730 int val;
731};
732%token <val> MY_TOKEN "MY TOKEN"
733%type <val> exp
734%%
735exp: "MY TOKEN";
736%%
737]])
738
da730230 739AT_BISON_CHECK([-o input.c input.y])
e59adf8f
PE
740
741AT_CLEANUP
b50d2359
AD
742
743
744## --------- ##
745## Require. ##
746## --------- ##
747
748m4_define([AT_CHECK_REQUIRE],
749[AT_SETUP([Require $1])
750AT_DATA_GRAMMAR([input.y],
751[[%require "$1";
752%%
753empty_file:;
754]])
da730230 755AT_BISON_CHECK([-o input.c input.y], $2, [], ignore)
b50d2359
AD
756AT_CLEANUP
757])
758
759AT_CHECK_REQUIRE(1.0, 0)
760AT_CHECK_REQUIRE(AT_PACKAGE_VERSION, 0)
761## FIXME: Some day augment this version number.
9b8a5ce0 762AT_CHECK_REQUIRE(100.0, 63)
1f6b3679
JD
763
764
765## ------------------------------------- ##
766## String aliases for character tokens. ##
767## ------------------------------------- ##
768
769AT_SETUP([String aliases for character tokens])
770
dab244d5
AD
771# Bison once thought a character token and its alias were different
772# symbols with the same user token number.
1f6b3679
JD
773
774AT_DATA_GRAMMAR([input.y],
775[[%token 'a' "a"
776%%
777start: 'a';
778%%
779]])
780
da730230 781AT_BISON_CHECK([-o input.c input.y])
1f6b3679
JD
782
783AT_CLEANUP
47aee066
JD
784
785
746ee38c
AD
786## -------------- ##
787## Symbol names. ##
788## -------------- ##
789
790AT_SETUP([Symbols])
791
55f48c48 792AT_BISON_OPTION_PUSHDEFS
746ee38c
AD
793AT_DATA_GRAMMAR([input.y],
794[[%token WITH-DASH
795%token WITHOUT_DASH "WITHOUT-DASH"
796%token WITH.PERIOD
797%token WITHOUT_PERIOD "WITHOUT.PERIOD"
d521ee19 798%code {
55f48c48
AD
799 ]AT_YYERROR_DECLARE[
800 ]AT_YYLEX_DECLARE[
d521ee19 801}
746ee38c
AD
802%%
803start: with-dash without_dash with.period without_period;
804with-dash: WITH-DASH;
805without_dash: "WITHOUT-DASH";
806with.period: WITH.PERIOD;
807without_period: "WITHOUT.PERIOD";
808%%
55f48c48
AD
809]AT_YYERROR_DEFINE[
810]AT_YYLEX_DEFINE[
746ee38c 811]])
55f48c48 812AT_BISON_OPTION_POPDEFS
746ee38c
AD
813
814# POSIX Yacc accept periods, but not dashes.
1048a1c9
AD
815AT_BISON_CHECK([--yacc -Wno-error input.y], [], [],
816[[input.y:9.8-16: warning: POSIX Yacc forbids dashes in symbol names: WITH-DASH [-Wyacc]
817input.y:18.8-16: warning: POSIX Yacc forbids dashes in symbol names: with-dash [-Wyacc]
746ee38c
AD
818]])
819
820# So warn about them.
821AT_BISON_CHECK([-Wyacc input.y], [], [],
73370a9d
VS
822[[input.y:9.8-16: warning: POSIX Yacc forbids dashes in symbol names: WITH-DASH [-Wyacc]
823input.y:18.8-16: warning: POSIX Yacc forbids dashes in symbol names: with-dash [-Wyacc]
746ee38c
AD
824]])
825
826# Dashes are fine for GNU Bison.
827AT_BISON_CHECK([-o input.c input.y])
828
829# Make sure we don't export silly token identifiers with periods or dashes.
91ce0b3a 830AT_COMPILE([input.o])
746ee38c
AD
831
832
82f3355e
JD
833# Periods are genuine letters, they can start identifiers.
834# Digits and dashes cannot.
746ee38c 835AT_DATA_GRAMMAR([input.y],
cdf3f113 836[[%token .GOOD
84a1cb5a
AD
837 -GOOD
838 1NV4L1D
82f3355e 839 -123
746ee38c 840%%
82f3355e 841start: .GOOD GOOD
746ee38c
AD
842]])
843AT_BISON_CHECK([-o input.c input.y], [1], [],
b8e7ad58
TR
844[[input.y:10.10: error: invalid character: '-'
845input.y:11.10-16: error: invalid identifier: '1NV4L1D'
846input.y:12.10: error: invalid character: '-'
746ee38c
AD
847]])
848
849AT_CLEANUP
850
851
ab2a9f57
AD
852## ----------------- ##
853## Numbered tokens. ##
854## ----------------- ##
855
856AT_SETUP([Numbered tokens])
857
83b60c97
JD
858AT_DATA_GRAMMAR([redecl.y],
859[[%token DECIMAL_1 11259375
860 HEXADECIMAL_1 0xabcdef
861 HEXADECIMAL_2 0xFEDCBA
862 DECIMAL_2 16702650
ab2a9f57 863%%
83b60c97 864start: DECIMAL_1 HEXADECIMAL_2;
8893145a
AD
865]])
866
83b60c97 867AT_BISON_CHECK([redecl.y], [1], [],
b8e7ad58 868[[redecl.y:10.10-22: error: user token number 11259375 redeclaration for HEXADECIMAL_1
b506d9bf 869redecl.y:9.8-16: previous declaration for DECIMAL_1
b8e7ad58 870redecl.y:12.10-18: error: user token number 16702650 redeclaration for DECIMAL_2
b506d9bf 871redecl.y:11.10-22: previous declaration for HEXADECIMAL_2
8893145a
AD
872]])
873
83b60c97 874AT_DATA_GRAMMAR([too-large.y],
ab2a9f57
AD
875[[%token TOO_LARGE_DEC 999999999999999999999
876 TOO_LARGE_HEX 0xFFFFFFFFFFFFFFFFFFF
877%%
878start: TOO_LARGE_DEC TOO_LARGE_HEX
879%%
880]])
881
83b60c97 882AT_BISON_CHECK([too-large.y], [1], [],
b8e7ad58
TR
883[[too-large.y:9.22-42: error: integer out of range: '999999999999999999999'
884too-large.y:10.24-44: error: integer out of range: '0xFFFFFFFFFFFFFFFFFFF'
ab2a9f57
AD
885]])
886
887AT_CLEANUP
888
889
47aee066
JD
890## --------------------- ##
891## Unclosed constructs. ##
892## --------------------- ##
893
894AT_SETUP([Unclosed constructs])
895
dab244d5
AD
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.
47aee066
JD
900
901AT_DATA([input.y],
902[[%token A "a
903%token B "b"
904%token AB "ab" // Used to complain that "ab" was already used.
905%token C '1
906%token TWO "2"
907%token TICK_TWELVE "'12" // Used to complain that "'12" was already used.
908
909%%
910
911start: ;
912
913// Used to report a syntax error because it didn't see any kind of symbol
914// identifier.
915%type <f> 'a
916;
917%type <f> "a
918;
919// Used to report a syntax error because it didn't see braced code.
920%destructor { free ($$)
921]])
922
da730230 923AT_BISON_CHECK([-o input.c input.y], 1, [],
b8e7ad58
TR
924[[input.y:1.10-2.0: error: missing '"' at end of line
925input.y:4.10-5.0: error: missing "'" at end of line
926input.y:14.11-15.0: error: missing "'" at end of line
927input.y:16.11-17.0: error: missing '"' at end of line
928input.y:19.13-20.0: error: missing '}' at end of file
929input.y:20.1: error: syntax error, unexpected end of file
47aee066
JD
930]])
931
932AT_CLEANUP
4d7370cb
JD
933
934
935## ------------------------- ##
936## %start after first rule. ##
937## ------------------------- ##
938
939AT_SETUP([%start after first rule])
940
dab244d5
AD
941# Bison once complained that a %start after the first rule was a
942# redeclaration of the start symbol.
4d7370cb
JD
943
944AT_DATA([input.y],
945[[%%
946false_start: ;
947start: false_start ;
948%start start;
949]])
950
da730230 951AT_BISON_CHECK([-o input.c input.y])
4d7370cb
JD
952
953AT_CLEANUP
26b8a438
JD
954
955
956## --------------------- ##
957## %prec takes a token. ##
958## --------------------- ##
959
960AT_SETUP([%prec takes a token])
961
962# Bison once allowed %prec sym where sym was a nonterminal.
963
964AT_DATA([input.y],
965[[%%
966start: PREC %prec PREC ;
967PREC: ;
968]])
969
da730230 970AT_BISON_CHECK([input.y], [1], [],
b8e7ad58 971[[input.y:3.1-4: error: rule given for PREC, which is a token
26b8a438
JD
972]])
973
974AT_CLEANUP
8e0a5e9e
JD
975
976
8bb3a2e7
JD
977## ------------------------------- ##
978## %prec's token must be defined. ##
979## ------------------------------- ##
980
981AT_SETUP([[%prec's token must be defined]])
982
983# According to POSIX, a %prec token must be defined separately.
984
985AT_DATA([[input.y]],
986[[%%
987start: %prec PREC ;
988]])
989
02354690 990AT_BISON_CHECK([[input.y]], [[0]], [],
73370a9d 991[[input.y:2.8-17: warning: token for %prec is not defined: PREC [-Wother]
8bb3a2e7
JD
992]])
993
994AT_CLEANUP
995
996
6afc30cc
JD
997## -------------------------------- ##
998## Reject unused %code qualifiers. ##
999## -------------------------------- ##
8e0a5e9e 1000
6afc30cc 1001AT_SETUP([Reject unused %code qualifiers])
8e0a5e9e
JD
1002
1003AT_DATA([input-c.y],
16dc6a9e
JD
1004[[%code q {}
1005%code bad {}
1006%code bad {}
8405b70c 1007%code format {}
8e0a5e9e
JD
1008%%
1009start: ;
1010]])
c6abeab1 1011AT_BISON_CHECK([[input-c.y]], [[1]], [],
b8e7ad58
TR
1012[[input-c.y:1.7: error: %code qualifier 'q' is not used
1013input-c.y:2.7-9: error: %code qualifier 'bad' is not used
1014input-c.y:3.7-9: error: %code qualifier 'bad' is not used
1015input-c.y:4.7-12: error: %code qualifier 'format' is not used
08af01c2 1016]])
8e0a5e9e
JD
1017
1018AT_DATA([input-c-glr.y],
16dc6a9e
JD
1019[[%code q {}
1020%code bad {}
1021 %code bad {}
8e0a5e9e
JD
1022%%
1023start: ;
1024]])
c6abeab1 1025AT_BISON_CHECK([[input-c-glr.y]], [[1]], [],
b8e7ad58
TR
1026[[input-c-glr.y:1.7: error: %code qualifier 'q' is not used
1027input-c-glr.y:2.7-9: error: %code qualifier 'bad' is not used
1028input-c-glr.y:3.8-10: error: %code qualifier 'bad' is not used
08af01c2 1029]])
8e0a5e9e
JD
1030
1031AT_DATA([input-c++.y],
16dc6a9e
JD
1032[[%code q {}
1033%code bad {}
1034 %code q {}
8e0a5e9e
JD
1035%%
1036start: ;
1037]])
c6abeab1 1038AT_BISON_CHECK([[input-c++.y]], [[1]], [],
b8e7ad58
TR
1039[[input-c++.y:1.7: error: %code qualifier 'q' is not used
1040input-c++.y:2.7-9: error: %code qualifier 'bad' is not used
1041input-c++.y:3.8: error: %code qualifier 'q' is not used
08af01c2 1042]])
8e0a5e9e
JD
1043
1044AT_DATA([input-c++-glr.y],
16dc6a9e
JD
1045[[%code bad {}
1046%code q {}
1047%code q {}
8e0a5e9e
JD
1048%%
1049start: ;
1050]])
c6abeab1 1051AT_BISON_CHECK([[input-c++-glr.y]], [[1]], [],
b8e7ad58
TR
1052[[input-c++-glr.y:1.7-9: error: %code qualifier 'bad' is not used
1053input-c++-glr.y:2.7: error: %code qualifier 'q' is not used
1054input-c++-glr.y:3.7: error: %code qualifier 'q' is not used
3fc65ead
JD
1055]])
1056
1057AT_DATA([special-char-@@.y],
16dc6a9e
JD
1058[[%code bad {}
1059%code q {}
1060%code q {}
3fc65ead
JD
1061%%
1062start: ;
1063]])
c6abeab1 1064AT_BISON_CHECK([[special-char-@@.y]], [[1]], [],
b8e7ad58
TR
1065[[special-char-@@.y:1.7-9: error: %code qualifier 'bad' is not used
1066special-char-@@.y:2.7: error: %code qualifier 'q' is not used
1067special-char-@@.y:3.7: error: %code qualifier 'q' is not used
3fc65ead
JD
1068]])
1069
1070AT_DATA([special-char-@:>@.y],
16dc6a9e
JD
1071[[%code bad {}
1072%code q {}
1073%code q {}
3fc65ead
JD
1074%%
1075start: ;
1076]])
c6abeab1 1077AT_BISON_CHECK([[special-char-@:>@.y]], [[1]], [],
b8e7ad58
TR
1078[[special-char-@:>@.y:1.7-9: error: %code qualifier 'bad' is not used
1079special-char-@:>@.y:2.7: error: %code qualifier 'q' is not used
1080special-char-@:>@.y:3.7: error: %code qualifier 'q' is not used
08af01c2 1081]])
8e0a5e9e
JD
1082
1083AT_CLEANUP
7eb8a0bc
JD
1084
1085
1086## ---------------- ##
1087## %define errors. ##
1088## ---------------- ##
1089
1090AT_SETUP([%define errors])
1091
0b6d43c5 1092AT_DATA([input-redefined.y],
16dc6a9e
JD
1093[[%define var "value1"
1094%define var "value1"
1095 %define var "value2"
1096%define special1 "@:>@"
1097%define special2 "@<:@"
7eb8a0bc
JD
1098%%
1099start: ;
1100]])
1101
0b6d43c5 1102AT_BISON_CHECK([[input-redefined.y]], [[1]], [],
b8e7ad58 1103[[input-redefined.y:2.9-11: error: %define variable 'var' redefined
6b1e1872 1104input-redefined.y:1.9-11: previous definition
b8e7ad58 1105input-redefined.y:3.10-12: error: %define variable 'var' redefined
6b1e1872 1106input-redefined.y:2.9-11: previous definition
0b6d43c5
JD
1107]])
1108
1109AT_DATA([input-unused.y],
1110[[%define var "value"
1111%%
1112start: ;
1113]])
1114
c6abeab1 1115AT_BISON_CHECK([[input-unused.y]], [[1]], [],
b8e7ad58 1116[[input-unused.y:1.9-11: error: %define variable 'var' is not used
7eb8a0bc
JD
1117]])
1118
1119AT_CLEANUP
c1d19e10 1120
58697c6d 1121
de5ab940
JD
1122## ----------------------------------- ##
1123## %define, --define, --force-define. ##
1124## ----------------------------------- ##
58697c6d 1125
c6abeab1 1126AT_SETUP([[%define, --define, --force-define]])
de5ab940 1127
c6abeab1 1128AT_DATA([[skel.c]],
de5ab940
JD
1129[[m4@&t@_divert_push(0)@
1130@output(b4_parser_file_name@)@
1131[var-dd: ]b4_percent_define_get([[var-dd]])[
1132var-ff: ]b4_percent_define_get([[var-ff]])[
de5ab940
JD
1133var-dfg: ]b4_percent_define_get([[var-dfg]])[
1134var-fd: ]b4_percent_define_get([[var-fd]])
1135m4@&t@_divert_pop(0)
1136]])
c6abeab1 1137AT_DATA([[input.y]],
0b6d43c5 1138[[%define var-dfg "gram"
58697c6d
AD
1139%%
1140start: ;
1141]])
de5ab940
JD
1142AT_BISON_CHECK([[-Dvar-dd=cmd-d1 -Dvar-dd=cmd-d2 \
1143 -Fvar-ff=cmd-f1 -Fvar-ff=cmd-f2 \
de5ab940
JD
1144 -Dvar-dfg=cmd-d -Fvar-dfg=cmd-f \
1145 -Fvar-fd=cmd-f -Dvar-fd=cmd-d \
c6abeab1 1146 --skeleton ./skel.c input.y]])
de5ab940
JD
1147AT_CHECK([[cat input.tab.c]], [[0]],
1148[[var-dd: cmd-d2
1149var-ff: cmd-f2
de5ab940
JD
1150var-dfg: cmd-f
1151var-fd: cmd-d
58697c6d
AD
1152]])
1153
c6abeab1 1154AT_DATA([[input-dg.y]],
0b6d43c5
JD
1155[[%define var "gram"
1156%%
1157start: ;
1158]])
0b6d43c5 1159AT_BISON_CHECK([[-Dvar=cmd-d input-dg.y]], [[1]], [],
b8e7ad58 1160[[input-dg.y:1.9-11: error: %define variable 'var' redefined
6b1e1872 1161<command line>:2: previous definition
0b6d43c5
JD
1162]])
1163
c6abeab1
JD
1164AT_DATA([[input-unused.y]],
1165[[%%
1166start: ;
1167]])
1168AT_BISON_CHECK([[-Dunused-d -Funused-f input-unused.y]], [[1]], [],
b8e7ad58
TR
1169[[<command line>:2: error: %define variable 'unused-d' is not used
1170<command line>:3: error: %define variable 'unused-f' is not used
c6abeab1
JD
1171]])
1172
58697c6d
AD
1173AT_CLEANUP
1174
c1d19e10 1175## --------------------------- ##
d782395d 1176## %define Boolean variables. ##
c1d19e10
PB
1177## --------------------------- ##
1178
d782395d 1179AT_SETUP([[%define Boolean variables]])
c1d19e10
PB
1180
1181AT_DATA([Input.y],
1182[[%language "Java"
1183%define public "maybe"
1184%define parser_class_name "Input"
1185%%
1186start: ;
1187]])
1188
da730230 1189AT_BISON_CHECK([[Input.y]], [1], [],
b8e7ad58 1190[[Input.y:2.9-14: error: invalid value for %define Boolean variable 'public'
c1d19e10
PB
1191]])
1192
1193AT_CLEANUP
d782395d 1194
f4909773
JD
1195## ------------------------ ##
1196## %define enum variables. ##
1197## ------------------------ ##
7254f6a8 1198
f4909773 1199AT_SETUP([[%define enum variables]])
7254f6a8 1200
f4909773 1201# Front-end.
7254f6a8 1202AT_DATA([[input.y]],
f3bc3386 1203[[%define lr.default-reduction bogus
7254f6a8
JD
1204%%
1205start: ;
1206]])
7254f6a8 1207AT_BISON_CHECK([[input.y]], [[1]], [[]],
f3bc3386
AD
1208[[input.y:1.9-28: error: invalid value for %define variable 'lr.default-reduction': 'bogus'
1209input.y:1.9-28: accepted value: 'most'
1210input.y:1.9-28: accepted value: 'consistent'
1211input.y:1.9-28: accepted value: 'accepting'
7254f6a8
JD
1212]])
1213
f4909773 1214# Back-end.
a974c1ec 1215# FIXME: these should be indented, but we shouldn't mess with the m4 yet
67212941 1216AT_DATA([[input.y]],
cf499cff 1217[[%define api.push-pull neither
67212941
JD
1218%%
1219start: ;
1220]])
1221AT_BISON_CHECK([[input.y]], [1], [],
b8e7ad58 1222[[input.y:1.9-21: error: invalid value for %define variable 'api.push-pull': 'neither'
c6c8de16
TR
1223input.y:1.9-21: accepted value: 'pull'
1224input.y:1.9-21: accepted value: 'push'
1225input.y:1.9-21: accepted value: 'both'
67212941
JD
1226]])
1227
1228AT_CLEANUP
1229
1230## -------------------------------- ##
1231## %define backward compatibility. ##
1232## -------------------------------- ##
1233
1234AT_SETUP([[%define backward compatibility]])
1235
1236# The error messages tell us whether underscores in these variables are
1237# being converted to dashes.
1238
d782395d 1239AT_DATA([[input.y]],
c373bf8b 1240[[%define api.push_pull "neither"
d782395d
JD
1241%%
1242start: ;
1243]])
da730230 1244AT_BISON_CHECK([[input.y]], [1], [],
2a8be426 1245[[input.y:1.9-21: warning: deprecated %define variable name: 'api.push_pull', use 'api.push-pull' [-Wdeprecated]
11b19212 1246input.y:1.9-21: error: invalid value for %define variable 'api.push-pull': 'neither'
c6c8de16
TR
1247input.y:1.9-21: accepted value: 'pull'
1248input.y:1.9-21: accepted value: 'push'
1249input.y:1.9-21: accepted value: 'both'
d782395d
JD
1250]])
1251
67212941 1252AT_DATA([[input.y]],
cf499cff 1253[[%define lr.keep_unreachable_states maybe
67212941
JD
1254%%
1255start: ;
1256]])
1257AT_BISON_CHECK([[input.y]], [1], [],
f3bc3386
AD
1258[[input.y:1.9-34: warning: deprecated %define variable name: 'lr.keep_unreachable_states', use 'lr.keep-unreachable-state' [-Wdeprecated]
1259input.y:1.9-34: error: invalid value for %define Boolean variable 'lr.keep-unreachable-state'
67212941
JD
1260]])
1261
171ad99d
AD
1262AT_DATA([[input.y]],
1263[[%define namespace "foo"
1264%define api.namespace "foo"
1265%%
1266start: ;
1267]])
1268AT_BISON_CHECK([[input.y]], [1], [],
2a8be426 1269[[input.y:1.9-17: warning: deprecated %define variable name: 'namespace', use 'api.namespace' [-Wdeprecated]
11b19212
AD
1270input.y:2.9-21: error: %define variable 'api.namespace' redefined
1271input.y:1.9-17: previous definition
171ad99d
AD
1272]])
1273
67212941
JD
1274AT_DATA([[input.y]],
1275[[%define foo_bar "baz"
1276%%
1277start: ;
1278]])
c6abeab1 1279AT_BISON_CHECK([[input.y]], [[1]], [],
b8e7ad58 1280[[input.y:1.9-15: error: %define variable 'foo_bar' is not used
67212941
JD
1281]])
1282
d782395d 1283AT_CLEANUP
793fbca5 1284
d9df47b6
JD
1285## ------------------------- ##
1286## Unused %define api.pure. ##
1287## ------------------------- ##
1288
1289AT_SETUP([[Unused %define api.pure]])
1290
1291# AT_CHECK_API_PURE(DECLS, VALUE)
1292# -------------------------------
1293# Make sure Bison reports that `%define api.pure VALUE' is unused when DECLS
1294# are specified.
1295m4_define([AT_CHECK_API_PURE],
1296[
1297AT_DATA([[input.y]],
1298[[%define api.pure ]$2[
1299]$1[
1300%%
1301start: ;
1302]])
1303
c6abeab1 1304AT_BISON_CHECK([[input.y]], [[1]], [],
b8e7ad58 1305[[input.y:1.9-16: error: %define variable 'api.pure' is not used
d9df47b6
JD
1306]])
1307])
1308
1309AT_CHECK_API_PURE([[%language "c++" %defines]], [[]])
cf499cff 1310AT_CHECK_API_PURE([[%language "c++" %defines]], [[false]])
d9df47b6 1311AT_CHECK_API_PURE([[%language "c++" %defines %glr-parser]], [[""]])
cf499cff
JD
1312AT_CHECK_API_PURE([[%language "c++" %defines %glr-parser]], [[false]])
1313AT_CHECK_API_PURE([[%language "java"]], [[true]])
1314AT_CHECK_API_PURE([[%language "java"]], [[false]])
d9df47b6
JD
1315
1316AT_CLEANUP
1317
793fbca5
JD
1318## -------------------------------- ##
1319## C++ namespace reference errors. ##
1320## -------------------------------- ##
1321
1322AT_SETUP([[C++ namespace reference errors]])
1323
1324# AT_CHECK_NAMESPACE_ERROR(NAMESPACE-DECL, ERROR, [ERROR], ...)
1325# -------------------------------------------------------------
1326# Make sure Bison reports all ERROR's for %define namespace "NAMESPACE-DECL".
1327m4_define([AT_CHECK_NAMESPACE_ERROR],
1328[
1329AT_DATA([[input.y]],
1330[[%language "C++"
1331%defines
67501061 1332%define api.namespace "]$1["
793fbca5
JD
1333%%
1334start: ;
1335]])
1336
da730230 1337AT_BISON_CHECK([[input.y]], [1], [],
793fbca5 1338[m4_foreach([b4_arg], m4_dquote(m4_shift($@)),
11b19212 1339[[input.y:3.9-21: error: ]b4_arg[
793fbca5
JD
1340]])])
1341])
1342
1343AT_CHECK_NAMESPACE_ERROR([[]],
1344 [[namespace reference is empty]])
1345AT_CHECK_NAMESPACE_ERROR([[ ]],
1346 [[namespace reference is empty]])
1347AT_CHECK_NAMESPACE_ERROR([[foo::::bar]],
1348 [[namespace reference has consecutive "::"]])
1349AT_CHECK_NAMESPACE_ERROR([[foo:: ::bar]],
1350 [[namespace reference has consecutive "::"]])
1351AT_CHECK_NAMESPACE_ERROR([[::::bar]],
1352 [[namespace reference has consecutive "::"]])
1353AT_CHECK_NAMESPACE_ERROR([[:: ::bar]],
1354 [[namespace reference has consecutive "::"]])
1355AT_CHECK_NAMESPACE_ERROR([[foo::bar:: ::]],
1356 [[namespace reference has consecutive "::"]],
1357 [[namespace reference has a trailing "::"]])
1358AT_CHECK_NAMESPACE_ERROR([[foo::bar::]],
1359 [[namespace reference has a trailing "::"]])
1360AT_CHECK_NAMESPACE_ERROR([[foo::bar:: ]],
1361 [[namespace reference has a trailing "::"]])
1362AT_CHECK_NAMESPACE_ERROR([[::]],
1363 [[namespace reference has a trailing "::"]])
1364
1365AT_CLEANUP
3208e3f4
JD
1366
1367## ------------------------ ##
1368## Bad character literals. ##
1369## ------------------------ ##
1370
1371# Bison used to accept character literals that were empty or contained
1372# too many characters.
1373
b70c7fb4
JD
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
3208e3f4
JD
1376# <http://lists.gnu.org/archive/html/bison-patches/2009-07/msg00019.html>.
1377
1378AT_SETUP([[Bad character literals]])
1379
1380AT_DATA([empty.y],
1381[[%%
1382start: '';
1383start: '
1384]])
ff020c30 1385AT_CHECK([[$PERL -e "print 'start: \'';" >> empty.y || exit 77]])
3208e3f4
JD
1386
1387AT_BISON_CHECK([empty.y], [1], [],
73370a9d
VS
1388[[empty.y:2.8-9: warning: empty character literal [-Wother]
1389empty.y:3.8-4.0: warning: empty character literal [-Wother]
b8e7ad58 1390empty.y:3.8-4.0: error: missing "'" at end of line
73370a9d 1391empty.y:4.8: warning: empty character literal [-Wother]
b8e7ad58 1392empty.y:4.8: error: missing "'" at end of file
3208e3f4
JD
1393]])
1394
1395AT_DATA([two.y],
1396[[%%
1397start: 'ab';
1398start: 'ab
1399]])
ff020c30 1400AT_CHECK([[$PERL -e "print 'start: \'ab';" >> two.y || exit 77]])
3208e3f4
JD
1401
1402AT_BISON_CHECK([two.y], [1], [],
73370a9d
VS
1403[[two.y:2.8-11: warning: extra characters in character literal [-Wother]
1404two.y:3.8-4.0: warning: extra characters in character literal [-Wother]
b8e7ad58 1405two.y:3.8-4.0: error: missing "'" at end of line
73370a9d 1406two.y:4.8-10: warning: extra characters in character literal [-Wother]
b8e7ad58 1407two.y:4.8-10: error: missing "'" at end of file
3208e3f4
JD
1408]])
1409
1410AT_DATA([three.y],
1411[[%%
1412start: 'abc';
1413start: 'abc
1414]])
ff020c30 1415AT_CHECK([[$PERL -e "print 'start: \'abc';" >> three.y || exit 77]])
3208e3f4
JD
1416
1417AT_BISON_CHECK([three.y], [1], [],
73370a9d
VS
1418[[three.y:2.8-12: warning: extra characters in character literal [-Wother]
1419three.y:3.8-4.0: warning: extra characters in character literal [-Wother]
b8e7ad58 1420three.y:3.8-4.0: error: missing "'" at end of line
73370a9d 1421three.y:4.8-11: warning: extra characters in character literal [-Wother]
b8e7ad58 1422three.y:4.8-11: error: missing "'" at end of file
3208e3f4
JD
1423]])
1424
1425AT_CLEANUP
c2724603
JD
1426
1427## ------------------------- ##
1428## Bad escapes in literals. ##
1429## ------------------------- ##
1430
1431AT_SETUP([[Bad escapes in literals]])
1432
1433AT_DATA([input.y],
1434[[%%
1435start: '\777' '\0' '\xfff' '\x0'
1436 '\uffff' '\u0000' '\Uffffffff' '\U00000000'
1437 '\ ' '\A';
1438]])
3bed3a75 1439
b70c7fb4 1440# It is not easy to create special characters, we cannot even trust tr.
3bed3a75
AD
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.
ff020c30 1444AT_CHECK([[$PERL -e 'print "start: \"\\\t\\\f\\\0\\\1\" ;";' >> input.y \
b70c7fb4 1445 || exit 77]])
c2724603
JD
1446
1447AT_BISON_CHECK([input.y], [1], [],
b8e7ad58 1448[[input.y:2.9-12: error: invalid number after \-escape: 777
73370a9d 1449input.y:2.8-13: warning: empty character literal [-Wother]
b8e7ad58 1450input.y:2.16-17: error: invalid number after \-escape: 0
73370a9d 1451input.y:2.15-18: warning: empty character literal [-Wother]
b8e7ad58 1452input.y:2.21-25: error: invalid number after \-escape: xfff
73370a9d 1453input.y:2.20-26: warning: empty character literal [-Wother]
b8e7ad58 1454input.y:2.29-31: error: invalid number after \-escape: x0
73370a9d 1455input.y:2.28-32: warning: empty character literal [-Wother]
b8e7ad58 1456input.y:3.9-14: error: invalid number after \-escape: uffff
73370a9d 1457input.y:3.8-15: warning: empty character literal [-Wother]
b8e7ad58 1458input.y:3.18-23: error: invalid number after \-escape: u0000
73370a9d 1459input.y:3.17-24: warning: empty character literal [-Wother]
b8e7ad58 1460input.y:3.27-36: error: invalid number after \-escape: Uffffffff
73370a9d 1461input.y:3.26-37: warning: empty character literal [-Wother]
b8e7ad58 1462input.y:3.40-49: error: invalid number after \-escape: U00000000
73370a9d 1463input.y:3.39-50: warning: empty character literal [-Wother]
b8e7ad58 1464input.y:4.9-10: error: invalid character after \-escape: ' '
73370a9d 1465input.y:4.8-11: warning: empty character literal [-Wother]
b8e7ad58 1466input.y:4.14-15: error: invalid character after \-escape: A
73370a9d 1467input.y:4.13-16: warning: empty character literal [-Wother]
b8e7ad58
TR
1468input.y:5.9-16: error: invalid character after \-escape: \t
1469input.y:5.17: error: invalid character after \-escape: \f
1470input.y:5.18: error: invalid character after \-escape: \0
1471input.y:5.19: error: invalid character after \-escape: \001
c2724603
JD
1472]])
1473
1474AT_CLEANUP
bf35c71c
JD
1475
1476## ------------------------- ##
1477## LAC: Errors for %define. ##
1478## ------------------------- ##
1479
1480AT_SETUP([[LAC: Errors for %define]])
1481
1482AT_DATA([[input.y]],
1483[[%%
1484start: ;
1485]])
1486
1487# parse.lac.* options are useless if LAC isn't actually activated.
1488AT_BISON_CHECK([[-Dparse.lac.es-capacity-initial=1 input.y]],
1489 [[1]], [],
b8e7ad58 1490[[<command line>:2: error: %define variable 'parse.lac.es-capacity-initial' is not used
bf35c71c 1491]])
107844a3
JD
1492AT_BISON_CHECK([[-Dparse.lac.memory-trace=full input.y]],
1493 [[1]], [],
b8e7ad58 1494[[<command line>:2: error: %define variable 'parse.lac.memory-trace' is not used
107844a3 1495]])
bf35c71c
JD
1496
1497AT_CLEANUP
bf0e44e8
JD
1498
1499## --------------------------------------------- ##
1500## -Werror is not affected by -Wnone and -Wall. ##
1501## --------------------------------------------- ##
1502
1503AT_SETUP([[-Werror is not affected by -Wnone and -Wall]])
1504
1505AT_DATA([[input.y]],
1506[[%%
1507foo-bar: ;
1508]])
1509
1510# -Werror is not enabled by -Wall or equivalent.
1511AT_BISON_CHECK([[-Wall input.y]], [[0]], [[]],
73370a9d 1512[[input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar [-Wyacc]
bf0e44e8
JD
1513]])
1514AT_BISON_CHECK([[-W input.y]], [[0]], [[]],
73370a9d 1515[[input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar [-Wyacc]
bf0e44e8
JD
1516]])
1517AT_BISON_CHECK([[-Wno-none input.y]], [[0]], [[]],
73370a9d 1518[[input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar [-Wyacc]
bf0e44e8
JD
1519]])
1520
1521# -Werror is not disabled by -Wnone or equivalent.
1522AT_BISON_CHECK([[-Werror,none,yacc input.y]], [[1]], [[]], [[stderr]])
1523AT_CHECK([[sed 's/^.*bison:/bison:/' stderr]], [[0]],
46bdb8ec 1524[[input.y:2.1-7: error: POSIX Yacc forbids dashes in symbol names: foo-bar [-Werror=yacc]
bf0e44e8
JD
1525]])
1526[mv stderr experr]
1527AT_BISON_CHECK([[-Werror,no-all,yacc input.y]], [[1]], [[]], [[experr]])
1528
1529AT_CLEANUP
32ae07ef
AD
1530
1531
1532## ------------------------------------------------------ ##
1533## %name-prefix and %define api.prefix are incompatible. ##
1534## ------------------------------------------------------ ##
1535
1536AT_SETUP([[%name-prefix and %define api.prefix are incompatible]])
1537
1538# AT_TEST(DIRECTIVES, OPTIONS, ERROR-LOCATION)
1539# --------------------------------------------
1540m4_pushdef([AT_TEST],
1541[AT_DATA([[input.y]],
1542[[$1
1543%%
1544exp:;
1545]])
1546AT_BISON_CHECK([[$2 input.y]], [[1]], [[]],
b8e7ad58 1547[[$3: error: '%name-prefix' and '%define api.prefix' cannot be used together
32ae07ef
AD
1548]])
1549])
1550
1551AT_TEST([%define api.prefix foo %name-prefix "bar"], [], [input.y:1.9-18])
1552AT_TEST([], [-Dapi.prefix=foo -p bar], [<command line>:2])
1553AT_TEST([%name-prefix "bar"], [-Dapi.prefix=foo], [<command line>:2])
1554AT_TEST([%define api.prefix foo], [-p bar], [input.y:1.9-18])
1555
1556m4_popdef([AT_TEST])
1557
1558AT_CLEANUP
8617d87e
AD
1559
1560
26313726
AD
1561## -------------- ##
1562## Stray $ or @. ##
1563## -------------- ##
1564
1565AT_SETUP([[Stray $ or @]])
1566
1c292035
AD
1567# Give %printer and %destructor "<*> exp TOK" instead of "<*>" to
1568# check that the warnings are reported once, not three times.
1569
26313726 1570AT_DATA_GRAMMAR([[input.y]],
4323e0da
AD
1571[[%type <TYPE> exp
1572%token <TYPE> TOK TOK2
1c292035 1573%destructor { $%; @%; } <*> exp TOK;
26313726 1574%initial-action { $%; @%; };
1c292035 1575%printer { $%; @%; } <*> exp TOK;
26313726 1576%%
1c292035 1577exp: TOK { $%; @%; $$ = $1; };
26313726
AD
1578]])
1579
1580AT_BISON_CHECK([[input.y]], 0, [],
4323e0da
AD
1581[[input.y:11.19: warning: stray '$' [-Wother]
1582input.y:11.23: warning: stray '@' [-Wother]
1583input.y:12.19: warning: stray '$' [-Wother]
1584input.y:12.23: warning: stray '@' [-Wother]
1585input.y:13.19: warning: stray '$' [-Wother]
1586input.y:13.23: warning: stray '@' [-Wother]
1587input.y:15.19: warning: stray '$' [-Wother]
1588input.y:15.23: warning: stray '@' [-Wother]
26313726
AD
1589]])
1590
1591AT_CLEANUP
1592
1593
1594
8617d87e
AD
1595## ---------------- ##
1596## Code injection. ##
1597## ---------------- ##
1598
1599
1600AT_SETUP([[Code injection]])
1601
1602m4_pattern_allow([^m4_errprintn$])
1603
1604# AT_TEST([MACRO])
1605# ----------------
1606# Try to have MACRO be run by bison.
1607m4_pushdef([AT_TEST],
1608[AT_DATA([[input.y]],
1609[[%type <$1(DEAD %type)> exp
1610%token <$1(DEAD %token)> a
4323e0da 1611%token b
8617d87e
AD
1612%initial-action
1613{
1614 $$;
1615 $<$1(DEAD %initial-action)>$
1616};
9a86ee60
AD
1617%printer
1618{
1619 $$
1620 $<$1(DEAD %printer)>$
1621} <> <*>;
1622%lex-param
1623{
1624 $1(DEAD %lex-param)
1625};
1626%parse-param
1627{
1628 $1(DEAD %parse-param)
1629};
8617d87e
AD
1630%%
1631exp:
4323e0da 1632 a a[name] b
8617d87e
AD
1633 {
1634 $$;
1635 $][1;
1636 $<$1(DEAD action 1)>$
1637 $<$1(DEAD action 2)>1
4323e0da 1638 $<$1(DEAD action 3)>name
8617d87e
AD
1639 $<$1(DEAD action 4)>0
1640 ;
1641 };
1642]])
1643
1644# FIXME: Provide a means to iterate over all the skeletons.
1645AT_BISON_CHECK([[-d input.y]])
1646AT_BISON_CHECK([[-d -S glr.c input.y]])
1647AT_BISON_CHECK([[-d -S lalr1.cc input.y]])
1648AT_BISON_CHECK([[-d -S glr.cc input.y]])
1649AT_BISON_CHECK([[ -S lalr1.java input.y]])
1650])
1651
1652AT_TEST([m4_errprintn])
1653AT_TEST([@:>@m4_errprintn])
1654
1655m4_popdef([AT_TEST])
1656
1657AT_CLEANUP
0f92546f
TR
1658
1659##----------------------- ##
1660## Deprecated directives. ##
1661## ---------------------- ##
1662
1663AT_SETUP([[Deprecated directives]])
1664
1665AT_KEYWORDS([[deprec]])
1666
1667AT_DATA_GRAMMAR([[input.y]],
1668[[
1669%default_prec
1670%error_verbose
ed91d427 1671%expect_rr 0
0f92546f
TR
1672%file-prefix = "foo"
1673%file-prefix
1674 =
1675"bar"
1676%fixed-output_files
1677%fixed_output-files
1678%fixed-output-files
1679%name-prefix= "foo"
1680%no-default_prec
1681%no_default-prec
1682%no_lines
1683%output = "foo"
1684%pure_parser
1685%token_table
ed91d427 1686%glr-parser
0f92546f
TR
1687%% exp : '0'
1688]])
1689
1690AT_BISON_CHECK([[input.y]], [[0]], [[]],
1691[[input.y:10.1-13: warning: deprecated directive: '%default_prec', use '%default-prec' [-Wdeprecated]
1692input.y:11.1-14: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
1693input.y:12.1-10: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
1694input.y:13.1-14: warning: deprecated directive: '%file-prefix =', use '%file-prefix' [-Wdeprecated]
1695input.y:14.1-15.2: warning: deprecated directive: '%file-prefix\n =', use '%file-prefix' [-Wdeprecated]
1696input.y:17.1-19: warning: deprecated directive: '%fixed-output_files', use '%fixed-output-files' [-Wdeprecated]
1697input.y:18.1-19: warning: deprecated directive: '%fixed_output-files', use '%fixed-output-files' [-Wdeprecated]
1698input.y:20.1-13: warning: deprecated directive: '%name-prefix=', use '%name-prefix' [-Wdeprecated]
1699input.y:21.1-16: warning: deprecated directive: '%no-default_prec', use '%no-default-prec' [-Wdeprecated]
1700input.y:22.1-16: warning: deprecated directive: '%no_default-prec', use '%no-default-prec' [-Wdeprecated]
1701input.y:23.1-9: warning: deprecated directive: '%no_lines', use '%no-lines' [-Wdeprecated]
1702input.y:24.1-9: warning: deprecated directive: '%output =', use '%output' [-Wdeprecated]
1703input.y:25.1-12: warning: deprecated directive: '%pure_parser', use '%pure-parser' [-Wdeprecated]
1704input.y:26.1-12: warning: deprecated directive: '%token_table', use '%token-table' [-Wdeprecated]
0f92546f
TR
1705]])
1706
1707AT_CLEANUP
1708
1709## ---------------------------- ##
1710## Unput's effect on locations. ##
1711## ---------------------------- ##
1712dnl When the scanner detects a deprecated construct, it unputs the correct
1713dnl version, but it should *not* have any impact on the scanner cursor. If it
1714dnl does, the locations of directives on the same line become erroneous.
1715
1716AT_SETUP([[Unput's effect on locations]])
1717
1718AT_KEYWORDS([[deprec]])
1719
1720AT_DATA_GRAMMAR([[input.y]],
1721[[
1722%glr-parser
1723%expect_rr 42 %expect_rr 42
1724 %expect_rr 42
1725%error_verbose %error_verbose
1726 %error_verbose
1727%% exp: '0'
1728]])
1729
1730AT_BISON_CHECK([[input.y]], [[1]], [[]],
1731[[input.y:11.1-10: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
1732input.y:11.15-24: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
1733input.y:12.15-24: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
1734input.y:13.1-14: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
1735input.y:13.16-29: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
1736input.y:13.11-21: error: %define variable 'parse.error' redefined
1737input.y:13-6: previous definition
1738input.y:14.16-29: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
1739input.y:14.11-21: error: %define variable 'parse.error' redefined
1740input.y:13.11-21: previous definition
1741]])
1742
1743AT_CLEANUP
1744
1745##--------------------------- ##
1746## Non-deprecated directives. ##
1747## -------------------------- ##
1748
1749AT_SETUP([[Non-deprecated directives]])
1750
1751AT_KEYWORDS([[deprec]])
1752
1753AT_DATA_GRAMMAR([[input.y]],
1754[[
1755%default-prec
1756%error-verbose
1757%expect-rr 42
1758%file-prefix "foo"
1759%file-prefix
1760"bar"
1761%fixed-output-files
1762%name-prefix "foo"
1763%no-default-prec
1764%no-lines
1765%output "foo"
1766%pure-parser
1767%token-table
1768%% exp : '0'
1769]])
1770
1771AT_BISON_CHECK([[input.y]], [[0]], [[]],
1772[[input.y: warning: %expect-rr applies only to GLR parsers [-Wother]
1773]])
1774
1775AT_CLEANUP