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