]> git.saurik.com Git - bison.git/blob - tests/input.at
* tests/push.at (Push Parsing: Memory Leak for Early Deletion): Do not
[bison.git] / tests / input.at
1 # Checking the Bison scanner. -*- Autotest -*-
2 # Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation,
3 # Inc.
4
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
8 # any later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 # 02110-1301, USA.
19
20 AT_BANNER([[Input Processing.]])
21
22 # Mostly test that we are robust to mistakes.
23
24
25 ## ------------ ##
26 ## Invalid $n. ##
27 ## ------------ ##
28
29 AT_SETUP([Invalid $n and @n])
30
31 AT_DATA([input.y],
32 [[%%
33 exp: { $$ = $1 ; };
34 exp: { @$ = @1 ; };
35 ]])
36
37 AT_CHECK([bison input.y], [1], [],
38 [[input.y:2.13-14: integer out of range: `$1'
39 input.y:3.13-14: integer out of range: `@1'
40 ]])
41
42 AT_CLEANUP
43
44
45 ## -------------- ##
46 ## Type Clashes. ##
47 ## -------------- ##
48
49 AT_SETUP([Type Clashes])
50
51 AT_DATA([input.y],
52 [[%union { int bar; }
53 %token foo
54 %type <bar> exp
55 %%
56 exp: foo { $$; } foo { $2; } foo
57 | foo
58 | /* Empty. */
59 ;
60 ]])
61
62 AT_CHECK([bison input.y], [1], [],
63 [[input.y:5.12-13: $$ for the midrule at $2 of `exp' has no declared type
64 input.y:5.24-25: $2 of `exp' has no declared type
65 input.y:5.6-32: warning: type clash on default action: <bar> != <>
66 input.y:6.6-8: warning: type clash on default action: <bar> != <>
67 input.y:7.5: warning: empty rule for typed nonterminal, and no action
68 ]])
69
70 AT_CLEANUP
71
72
73 # _AT_UNUSED_VALUES_DECLARATIONS()
74 # --------------------------------------------
75 # Generate the token, type, and destructor
76 # declarations for the unused values tests.
77
78 m4_define([_AT_UNUSED_VALUES_DECLARATIONS],
79 [[[%token <integer> INT;
80 %type <integer> a b c d e f g h i j k l;
81 %destructor { destroy ($$); } INT a b c d e f g h i j k l;]]])
82
83
84 # AT_CHECK_UNUSED_VALUES(DECLARATIONS_AFTER, CHECK_MIDRULE_VALUES)
85 # ------------------------------------------------------------------
86 # Generate a grammar to test unused values,
87 # compile it, run it. If DECLARATIONS_AFTER
88 # is set, then the token, type, and destructor
89 # declarations are generated after the rules
90 # rather than before. If CHECK_MIDRULE_VALUES
91 # is set, then --warnings=midrule-values is
92 # set.
93
94 m4_define([AT_CHECK_UNUSED_VALUES],
95 [AT_DATA([input.y],
96 m4_ifval($1, [
97
98
99 ], [_AT_UNUSED_VALUES_DECLARATIONS
100 ])[[%%
101 start:
102 'a' a { $]2[ } | 'b' b { $]2[ } | 'c' c { $]2[ } | 'd' d { $]2[ } | 'e' e { $]2[ }
103 | 'f' f { $]2[ } | 'g' g { $]2[ } | 'h' h { $]2[ } | 'i' i { $]2[ } | 'j' j { $]2[ }
104 | 'k' k { $]2[ } | 'l' l { $]2[ }
105 ;
106
107 a: INT | INT { } INT { } INT { };
108 b: INT | /* empty */;
109 c: INT | INT { $]1[ } INT { $<integer>2 } INT { $<integer>4 };
110 d: INT | INT { } INT { $]1[ } INT { $<integer>2 };
111 e: INT | INT { } INT { } INT { $]1[ };
112 f: INT | INT { } INT { } INT { $]$[ = $]1[ + $]3[ + $]5[; };
113 g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
114 h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
115 i: INT | INT INT { } { $]$[ = $]1[ + $]2[; };
116 j: INT | INT INT { $<integer>$ = 1; } { $]$[ = $]1[ + $]2[; };
117 k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
118 l: INT | INT { $<integer>$ = $<integer>1; } INT { $<integer>$ = $<integer>2 + $<integer>3; } INT { $<integer>$ = $<integer>4 + $<integer>5; };]]m4_ifval($1, [
119 _AT_UNUSED_VALUES_DECLARATIONS])
120 )
121
122 AT_CHECK([bison]m4_ifval($2, [ --warnings=midrule-values ])[ input.y], [0], [],
123 [[input.y:11.10-32: warning: unset value: $]$[
124 input.y:11.10-32: warning: unused value: $]1[
125 input.y:11.10-32: warning: unused value: $]3[
126 input.y:11.10-32: warning: unused value: $]5[
127 input.y:12.9: warning: empty rule for typed nonterminal, and no action
128 ]]m4_ifval($2, [[[input.y:13.14-19: warning: unset value: $$
129 input.y:13.25-39: warning: unset value: $$
130 ]]])[[input.y:13.10-59: warning: unset value: $]$[
131 input.y:13.10-59: warning: unused value: $]3[
132 input.y:13.10-59: warning: unused value: $]5[
133 ]]m4_ifval($2, [[[input.y:14.14-16: warning: unset value: $$
134 ]]])[[input.y:14.10-47: warning: unset value: $]$[
135 input.y:14.10-47: warning: unused value: $]3[
136 input.y:14.10-47: warning: unused value: $]5[
137 input.y:15.10-36: warning: unset value: $]$[
138 input.y:15.10-36: warning: unused value: $]3[
139 input.y:15.10-36: warning: unused value: $]5[
140 input.y:17.10-58: warning: unset value: $]$[
141 input.y:17.10-58: warning: unused value: $]1[
142 ]]m4_ifval($2, [[[input.y:17.10-58: warning: unused value: $]2[
143 ]]])[[input.y:17.10-58: warning: unused value: $]3[
144 ]]m4_ifval($2, [[[input.y:17.10-58: warning: unused value: $]4[
145 ]]])[[input.y:17.10-58: warning: unused value: $]5[
146 input.y:18.10-72: warning: unset value: $]$[
147 input.y:18.10-72: warning: unused value: $]1[
148 input.y:18.10-72: warning: unused value: $]3[
149 ]]m4_ifval($2, [[[input.y:18.10-72: warning: unused value: $]4[
150 ]]])[[input.y:18.10-72: warning: unused value: $]5[
151 ]]m4_ifval($2, [[[input.y:20.10-55: warning: unused value: $]3[
152 ]]])[[input.y:21.10-68: warning: unset value: $]$[
153 input.y:21.10-68: warning: unused value: $]1[
154 input.y:21.10-68: warning: unused value: $]2[
155 ]]m4_ifval($2, [[[input.y:21.10-68: warning: unused value: $]4[
156 ]]]))])
157
158
159 ## --------------- ##
160 ## Unused values. ##
161 ## --------------- ##
162
163 AT_SETUP([Unused values])
164 AT_CHECK_UNUSED_VALUES
165 AT_CHECK_UNUSED_VALUES(, [1])
166 AT_CLEANUP
167
168
169 ## ------------------------------------------ ##
170 ## Unused values before symbol declarations. ##
171 ## ------------------------------------------ ##
172
173 AT_SETUP([Unused values before symbol declarations])
174 AT_CHECK_UNUSED_VALUES([1])
175 AT_CHECK_UNUSED_VALUES([1], [1])
176 AT_CLEANUP
177
178
179 ## --------------------------------------------- ##
180 ## Default %printer and %destructor redeclared. ##
181 ## --------------------------------------------- ##
182
183 AT_SETUP([Default %printer and %destructor redeclared])
184
185 AT_DATA([[input.y]],
186 [[%destructor { destroy ($$); } <*> <*>
187 %printer { destroy ($$); } <*> <*>
188
189 %destructor { destroy ($$); } <*>
190 %printer { destroy ($$); } <*>
191
192 %destructor { destroy ($$); } <> <>
193 %printer { destroy ($$); } <> <>
194
195 %destructor { destroy ($$); } <>
196 %printer { destroy ($$); } <>
197
198 %%
199
200 start: ;
201
202 %destructor { destroy ($$); } <*>;
203 %printer { destroy ($$); } <*>;
204
205 %destructor { destroy ($$); } <>;
206 %printer { destroy ($$); } <>;
207 ]])
208
209 AT_CHECK([bison input.y], [1], [],
210 [[input.y:1.13-29: redeclaration for default tagged %destructor
211 input.y:1.13-29: previous declaration
212 input.y:2.10-26: redeclaration for default tagged %printer
213 input.y:2.10-26: previous declaration
214 input.y:4.13-29: redeclaration for default tagged %destructor
215 input.y:1.13-29: previous declaration
216 input.y:5.10-26: redeclaration for default tagged %printer
217 input.y:2.10-26: previous declaration
218 input.y:7.13-29: redeclaration for default tagless %destructor
219 input.y:7.13-29: previous declaration
220 input.y:8.10-26: redeclaration for default tagless %printer
221 input.y:8.10-26: previous declaration
222 input.y:10.13-29: redeclaration for default tagless %destructor
223 input.y:7.13-29: previous declaration
224 input.y:11.10-26: redeclaration for default tagless %printer
225 input.y:8.10-26: previous declaration
226 input.y:17.13-29: redeclaration for default tagged %destructor
227 input.y:4.13-29: previous declaration
228 input.y:18.10-26: redeclaration for default tagged %printer
229 input.y:5.10-26: previous declaration
230 input.y:20.13-29: redeclaration for default tagless %destructor
231 input.y:10.13-29: previous declaration
232 input.y:21.10-26: redeclaration for default tagless %printer
233 input.y:11.10-26: previous declaration
234 ]])
235
236 AT_CLEANUP
237
238
239 ## ---------------------------------------------- ##
240 ## Per-type %printer and %destructor redeclared. ##
241 ## ---------------------------------------------- ##
242
243 AT_SETUP([Per-type %printer and %destructor redeclared])
244
245 AT_DATA([[input.y]],
246 [[%destructor { destroy ($$); } <field1> <field2>
247 %printer { destroy ($$); } <field1> <field2>
248
249 %destructor { destroy ($$); } <field1> <field1>
250 %printer { destroy ($$); } <field2> <field2>
251
252 %%
253
254 start: ;
255
256 %destructor { destroy ($$); } <field2> <field1>;
257 %printer { destroy ($$); } <field2> <field1>;
258 ]])
259
260 AT_CHECK([bison input.y], [1], [],
261 [[input.y:4.13-29: %destructor redeclaration for <field1>
262 input.y:1.13-29: previous declaration
263 input.y:4.13-29: %destructor redeclaration for <field1>
264 input.y:4.13-29: previous declaration
265 input.y:5.10-26: %printer redeclaration for <field2>
266 input.y:2.10-26: previous declaration
267 input.y:5.10-26: %printer redeclaration for <field2>
268 input.y:5.10-26: previous declaration
269 input.y:11.13-29: %destructor redeclaration for <field1>
270 input.y:4.13-29: previous declaration
271 input.y:11.13-29: %destructor redeclaration for <field2>
272 input.y:1.13-29: previous declaration
273 input.y:12.10-26: %printer redeclaration for <field1>
274 input.y:2.10-26: previous declaration
275 input.y:12.10-26: %printer redeclaration for <field2>
276 input.y:5.10-26: previous declaration
277 ]])
278
279 AT_CLEANUP
280
281
282 ## ---------------------------------------- ##
283 ## Unused values with default %destructor. ##
284 ## ---------------------------------------- ##
285
286 AT_SETUP([Unused values with default %destructor])
287
288 AT_DATA([[input.y]],
289 [[%destructor { destroy ($$); } <>
290 %type <tag> tagged
291
292 %%
293
294 start: end end tagged tagged { $<tag>1; $3; } ;
295 end: { } ;
296 tagged: { } ;
297 ]])
298
299 AT_CHECK([bison input.y], [0], [],
300 [[input.y:6.8-45: warning: unset value: $$
301 input.y:6.8-45: warning: unused value: $2
302 input.y:7.6-8: warning: unset value: $$
303 ]])
304
305 AT_DATA([[input.y]],
306 [[%destructor { destroy ($$); } <*>
307 %type <tag> tagged
308
309 %%
310
311 start: end end tagged tagged { $<tag>1; $3; } ;
312 end: { } ;
313 tagged: { } ;
314 ]])
315
316 AT_CHECK([bison input.y], [0], [],
317 [[input.y:6.8-45: warning: unused value: $4
318 input.y:8.9-11: warning: unset value: $$
319 ]])
320
321 AT_CLEANUP
322
323
324 ## ----------------------------------------- ##
325 ## Unused values with per-type %destructor. ##
326 ## ----------------------------------------- ##
327
328 AT_SETUP([Unused values with per-type %destructor])
329
330 AT_DATA([[input.y]],
331 [[%destructor { destroy ($$); } <field1>
332 %type <field1> start end
333
334 %%
335
336 start: end end { $1; } ;
337 end: { } ;
338 ]])
339
340 AT_CHECK([bison input.y], [0], [],
341 [[input.y:6.8-22: warning: unset value: $$
342 input.y:6.8-22: warning: unused value: $2
343 input.y:7.6-8: warning: unset value: $$
344 ]])
345
346 AT_CLEANUP
347
348
349 ## ---------------------- ##
350 ## Incompatible Aliases. ##
351 ## ---------------------- ##
352
353 AT_SETUP([Incompatible Aliases])
354
355 AT_DATA([input.y],
356 [[%token foo "foo"
357
358 %type <bar> foo
359 %printer {bar} foo
360 %destructor {bar} foo
361 %left foo
362
363 %type <baz> "foo"
364 %printer {baz} "foo"
365 %destructor {baz} "foo"
366 %left "foo"
367
368 %%
369 exp: foo;
370 ]])
371
372 AT_CHECK([bison input.y], [1], [],
373 [[input.y:8.7-11: %type redeclaration for foo
374 input.y:3.7-11: previous declaration
375 input.y:10.13-17: %destructor redeclaration for foo
376 input.y:5.13-17: previous declaration
377 input.y:9.10-14: %printer redeclaration for foo
378 input.y:4.10-14: previous declaration
379 input.y:11.1-5: %left redeclaration for foo
380 input.y:6.1-5: previous declaration
381 ]])
382
383 AT_CLEANUP
384
385
386
387 ## ----------------------- ##
388 ## Torturing the Scanner. ##
389 ## ----------------------- ##
390
391 # Be sure to compile and run, so that the C compiler checks what
392 # we do.
393
394 AT_SETUP([Torturing the Scanner])
395
396
397 AT_DATA([input.y], [])
398 AT_CHECK([bison input.y], [1], [],
399 [[input.y:1.1: syntax error, unexpected end of file
400 ]])
401
402
403 AT_DATA([input.y],
404 [{}
405 ])
406 AT_CHECK([bison input.y], [1], [],
407 [[input.y:1.1-2: syntax error, unexpected {...}
408 ]])
409
410
411 AT_DATA_GRAMMAR([input.y],
412 [[%{
413 /* This is seen in GCC: a %{ and %} in middle of a comment. */
414 const char *foo = "So %{ and %} can be here too.";
415
416 #if 0
417 /* These examples test Bison while not stressing C compilers too much.
418 Many C compilers mishandle backslash-newlines, so this part of the
419 test is inside "#if 0". The comment and string are written so that
420 the "#endif" will be seen regardless of the C compiler bugs that we
421 know about, namely:
422
423 HP C (as of late 2002) mishandles *\[newline]\[newline]/ within a
424 comment.
425
426 The Apple Darwin compiler (as of late 2002) mishandles
427 \\[newline]' within a character constant.
428
429 */
430
431 /\
432 * A comment with backslash-newlines in it. %} *\
433 \
434 /
435 /* { Close the above comment, if the C compiler mishandled it. */
436
437 char str[] = "\\
438 " A string with backslash-newlines in it %{ %} \\
439 \
440 "";
441
442 char apostrophe = '\'';
443 #endif
444
445 #include <stdio.h>
446 #include <stdlib.h>
447 %}
448 /* %{ and %} can be here too. */
449
450 %{
451 /* Exercise pre-prologue dependency to %union. */
452 typedef int value;
453 %}
454
455 /* Exercise M4 quoting: '@:>@@:>@', 0. */
456
457 /* Also exercise %union. */
458 %union
459 {
460 value ival; /* A comment to exercise an old bug. */
461 };
462
463
464 /* Exercise post-prologue dependency to %union. */
465 %{
466 static YYSTYPE value_as_yystype (value val);
467
468 /* Exercise quotes in declarations. */
469 char quote[] = "@:>@@:>@,";
470 %}
471
472 %{
473 static void yyerror (const char *s);
474 static int yylex (void);
475 %}
476
477 %type <ival> '@<:@'
478
479 /* Exercise quotes in strings. */
480 %token FAKE "fake @<:@@:>@ \a\b\f\n\r\t\v\"\'\?\\\u005B\U0000005c ??!??'??(??)??-??/??<??=??> \x1\1"
481
482 %%
483 /* Exercise M4 quoting: '@:>@@:>@', @<:@, 1. */
484 exp: '@<:@' '\1' two '$' '@' '{' oline output.or.oline.opt
485 {
486 /* Exercise quotes in braces. */
487 char tmp[] = "@<:@%c@:>@,\n";
488 printf (tmp, $1);
489 }
490 ;
491
492 two: '\x000000000000000000000000000000000000000000000000000000000000000000002';
493 oline: '@' 'o' 'l' 'i' 'n' 'e' '@' '_' '_' 'o' 'l' 'i' 'n' 'e' '_' '_';
494 output.or.oline.opt: ;|oline;;|output;;;
495 output: '#' 'o' 'u' 't' 'p' 'u' 't' ' ';
496 %%
497 /* Exercise M4 quoting: '@:>@@:>@', @<:@, 2. */
498
499 static YYSTYPE
500 value_as_yystype (value val)
501 {
502 YYSTYPE res;
503 res.ival = val;
504 return res;
505 }
506
507 static int
508 yylex (void)
509 {
510 static char const input[] = "@<:@\1\2$@{@oline@__@&t@oline__\
511 #output "; /* "
512 */
513 static size_t toknum;
514 if (! (toknum < sizeof input))
515 abort ();
516 yylval = value_as_yystype (input[toknum]);
517 return input[toknum++];
518 }
519
520 static void
521 yyerror (const char *msg)
522 {
523 fprintf (stderr, "%s\n", msg);
524 }
525 ]])
526
527 # Pacify Emacs'font-lock-mode: "
528
529 AT_DATA([main.c],
530 [[typedef int value;
531 #include "input.h"
532
533 int yyparse (void);
534
535 int
536 main (void)
537 {
538 return yyparse ();
539 }
540 ]])
541
542 AT_CHECK([bison -d -v -o input.c input.y])
543 AT_COMPILE([input.o], [-c input.c])
544 AT_COMPILE([main.o], [-c main.c])
545 AT_COMPILE([input], [input.o main.o])
546 AT_PARSER_CHECK([./input], 0,
547 [[[@<:@],
548 ]])
549
550 AT_CLEANUP
551
552
553 ## ---------------------- ##
554 ## Typed symbol aliases. ##
555 ## ---------------------- ##
556
557 AT_SETUP([Typed symbol aliases])
558
559 # Bison 2.0 broke typed symbol aliases - ensure they work.
560
561 AT_DATA_GRAMMAR([input.y],
562 [[%union
563 {
564 int val;
565 };
566 %token <val> MY_TOKEN "MY TOKEN"
567 %type <val> exp
568 %%
569 exp: "MY TOKEN";
570 %%
571 ]])
572
573 AT_CHECK([bison -o input.c input.y])
574
575 AT_CLEANUP
576
577
578 ## --------- ##
579 ## Require. ##
580 ## --------- ##
581
582 m4_define([AT_CHECK_REQUIRE],
583 [AT_SETUP([Require $1])
584 AT_DATA_GRAMMAR([input.y],
585 [[%require "$1";
586 %%
587 empty_file:;
588 ]])
589 AT_CHECK([bison -o input.c input.y], $2, [], ignore)
590 AT_CLEANUP
591 ])
592
593 AT_CHECK_REQUIRE(1.0, 0)
594 AT_CHECK_REQUIRE(AT_PACKAGE_VERSION, 0)
595 ## FIXME: Some day augment this version number.
596 AT_CHECK_REQUIRE(100.0, 63)
597
598
599 ## ------------------------------------- ##
600 ## String aliases for character tokens. ##
601 ## ------------------------------------- ##
602
603 AT_SETUP([String aliases for character tokens])
604
605 # Bison once thought a character token and its alias were different symbols
606 # with the same user token number.
607
608 AT_DATA_GRAMMAR([input.y],
609 [[%token 'a' "a"
610 %%
611 start: 'a';
612 %%
613 ]])
614
615 AT_CHECK([bison -o input.c input.y])
616
617 AT_CLEANUP
618
619
620 ## --------------------- ##
621 ## Unclosed constructs. ##
622 ## --------------------- ##
623
624 AT_SETUP([Unclosed constructs])
625
626 # Bison's scan-gram.l once forgot to STRING_FINISH some unclosed constructs, so
627 # they were prepended to whatever it STRING_GROW'ed next. It also threw them
628 # away rather than returning them to the parser. The effect was confusing
629 # subsequent error messages.
630
631 AT_DATA([input.y],
632 [[%token A "a
633 %token B "b"
634 %token AB "ab" // Used to complain that "ab" was already used.
635 %token C '1
636 %token TWO "2"
637 %token TICK_TWELVE "'12" // Used to complain that "'12" was already used.
638
639 %%
640
641 start: ;
642
643 // Used to report a syntax error because it didn't see any kind of symbol
644 // identifier.
645 %type <f> 'a
646 ;
647 %type <f> "a
648 ;
649 // Used to report a syntax error because it didn't see braced code.
650 %destructor { free ($$)
651 ]])
652
653 AT_CHECK([bison -o input.c input.y], 1, [],
654 [[input.y:1.10-2.0: missing `"' at end of line
655 input.y:4.10-5.0: missing `'' at end of line
656 input.y:14.11-15.0: missing `'' at end of line
657 input.y:16.11-17.0: missing `"' at end of line
658 input.y:19.13-20.0: missing `}' at end of file
659 input.y:20.1: syntax error, unexpected end of file
660 ]])
661
662 AT_CLEANUP
663
664
665 ## ------------------------- ##
666 ## %start after first rule. ##
667 ## ------------------------- ##
668
669 AT_SETUP([%start after first rule])
670
671 # Bison once complained that a %start after the first rule was a redeclaration
672 # of the start symbol.
673
674 AT_DATA([input.y],
675 [[%%
676 false_start: ;
677 start: false_start ;
678 %start start;
679 ]])
680
681 AT_CHECK([bison -o input.c input.y])
682
683 AT_CLEANUP
684
685
686 ## --------------------- ##
687 ## %prec takes a token. ##
688 ## --------------------- ##
689
690 AT_SETUP([%prec takes a token])
691
692 # Bison once allowed %prec sym where sym was a nonterminal.
693
694 AT_DATA([input.y],
695 [[%%
696 start: PREC %prec PREC ;
697 PREC: ;
698 ]])
699
700 AT_CHECK([bison input.y], [1], [],
701 [[input.y:3.1-4: rule given for PREC, which is a token
702 ]])
703
704 AT_CLEANUP
705
706
707 ## -------------------------------- ##
708 ## Reject unused %code qualifiers. ##
709 ## -------------------------------- ##
710
711 AT_SETUP([Reject unused %code qualifiers])
712
713 AT_DATA([input-c.y],
714 [[%code q {}
715 %code bad {}
716 %code bad {}
717 %code format {}
718 %%
719 start: ;
720 ]])
721 AT_CHECK([[bison input-c.y]], [0], [],
722 [[input-c.y:1.7: warning: %code qualifier `q' is not used
723 input-c.y:2.7-9: warning: %code qualifier `bad' is not used
724 input-c.y:3.7-9: warning: %code qualifier `bad' is not used
725 input-c.y:4.7-12: warning: %code qualifier `format' is not used
726 ]])
727
728 AT_DATA([input-c-glr.y],
729 [[%code q {}
730 %code bad {}
731 %code bad {}
732 %%
733 start: ;
734 ]])
735 AT_CHECK([[bison input-c-glr.y]], [0], [],
736 [[input-c-glr.y:1.7: warning: %code qualifier `q' is not used
737 input-c-glr.y:2.7-9: warning: %code qualifier `bad' is not used
738 input-c-glr.y:3.8-10: warning: %code qualifier `bad' is not used
739 ]])
740
741 AT_DATA([input-c++.y],
742 [[%code q {}
743 %code bad {}
744 %code q {}
745 %%
746 start: ;
747 ]])
748 AT_CHECK([[bison input-c++.y]], [0], [],
749 [[input-c++.y:1.7: warning: %code qualifier `q' is not used
750 input-c++.y:2.7-9: warning: %code qualifier `bad' is not used
751 input-c++.y:3.8: warning: %code qualifier `q' is not used
752 ]])
753
754 AT_DATA([input-c++-glr.y],
755 [[%code bad {}
756 %code q {}
757 %code q {}
758 %%
759 start: ;
760 ]])
761 AT_CHECK([[bison input-c++-glr.y]], [0], [],
762 [[input-c++-glr.y:1.7-9: warning: %code qualifier `bad' is not used
763 input-c++-glr.y:2.7: warning: %code qualifier `q' is not used
764 input-c++-glr.y:3.7: warning: %code qualifier `q' is not used
765 ]])
766
767 AT_DATA([special-char-@@.y],
768 [[%code bad {}
769 %code q {}
770 %code q {}
771 %%
772 start: ;
773 ]])
774 AT_CHECK([[bison special-char-@@.y]], [0], [],
775 [[special-char-@@.y:1.7-9: warning: %code qualifier `bad' is not used
776 special-char-@@.y:2.7: warning: %code qualifier `q' is not used
777 special-char-@@.y:3.7: warning: %code qualifier `q' is not used
778 ]])
779
780 AT_DATA([special-char-@:>@.y],
781 [[%code bad {}
782 %code q {}
783 %code q {}
784 %%
785 start: ;
786 ]])
787 AT_CHECK([[bison special-char-@:>@.y]], [0], [],
788 [[special-char-@:>@.y:1.7-9: warning: %code qualifier `bad' is not used
789 special-char-@:>@.y:2.7: warning: %code qualifier `q' is not used
790 special-char-@:>@.y:3.7: warning: %code qualifier `q' is not used
791 ]])
792
793 AT_CLEANUP
794
795
796 ## ---------------- ##
797 ## %define errors. ##
798 ## ---------------- ##
799
800 AT_SETUP([%define errors])
801
802 AT_DATA([input.y],
803 [[%define var "value1"
804 %define var "value1"
805 %define var "value2"
806 %define special1 "@:>@"
807 %define special2 "@<:@"
808 %%
809 start: ;
810 ]])
811
812 AT_CHECK([[bison input.y]], [0], [],
813 [[input.y:2.9-11: warning: %define variable `var' redefined
814 input.y:1.9-11: warning: previous definition
815 input.y:3.10-12: warning: %define variable `var' redefined
816 input.y:2.9-11: warning: previous definition
817 input.y:1.9-11: warning: %define variable `var' is not used
818 input.y:2.9-11: warning: %define variable `var' is not used
819 input.y:3.10-12: warning: %define variable `var' is not used
820 input.y:4.9-16: warning: %define variable `special1' is not used
821 input.y:5.9-16: warning: %define variable `special2' is not used
822 ]])
823
824 AT_CLEANUP
825
826 ## --------------------------- ##
827 ## Boolean %define variables. ##
828 ## --------------------------- ##
829
830 AT_SETUP([Boolean %define variables])
831
832 AT_DATA([Input.y],
833 [[%language "Java"
834 %define public "maybe"
835 %define parser_class_name "Input"
836 %%
837 start: ;
838 ]])
839
840 AT_CHECK([[bison Input.y]], [1], [],
841 [[Input.y:2.9-14: invalid value for %define boolean variable `public'
842 ]])
843
844 AT_CLEANUP