Compare commits

...
39 Commits
Author SHA1 Message Date
Akim Demaille 013a695add version 3.2.91
* NEWS: Record release date.
2019-01-19 07:25:25 +01:00
Akim Demaille 54ed577da0 style: various fixes
Some reported by syntax-check.

* po/POTFILES.in: Add fixits.cc.
* src/muscle-tab.c: Don't cast for free.
* src/files.c: Reduce scopes.
* cfg.mk: We need the cast for free in muscle_percent_define_insert.
2019-01-18 08:43:06 +01:00
Akim Demaille 4a690d3d19 doc: document -ffixit and --update
* doc/bison.texi (Bison Options): here.
2019-01-18 06:55:01 +01:00
Akim Demaille cd1a9f076c doc: style fixes
* doc/bison.texi: Use @kbd where appropriate.
Update ^~~~ marks for caret-errors.
* build-aux/cross-options.pl: Do not add quotes to %define's argument.
2019-01-18 06:55:01 +01:00
Akim Demaille 7a0f681cb8 NEWS: update for fixits and --update 2019-01-18 06:55:01 +01:00
Akim Demaille eb0f3e79e0 fixits: handle duplicates of %name-prefix
The test case "Deprecated directives" (currently 56) no longer emits
warnings after 'bison -u'!

* src/files.h, src/files.c (spec_name_prefix_loc): New.
* src/parse-gram.y (handle_name_prefix): Emit fixits for duplicate
%name-prefix.
* tests/input.at (Deprecated directives): Adjust.
2019-01-17 18:09:38 +01:00
Akim Demaille 25b7421c40 regen 2019-01-17 18:09:38 +01:00
Akim Demaille e86adac52d fixits: handle %file-prefix
* src/files.h, src/files.c (spec_file_prefix_loc): New.
* src/scan-gram.l (%file-prefix): Delegate diagnostics to...
* src/parse-gram.y (handle_file_prefix): here.
* src/complain.c (duplicate_directive): Quote the directive.
* tests/input.at: Adjust.
2019-01-17 18:09:38 +01:00
Akim Demaille 5879c8dc5a fixits: handle per-rule duplicates
* src/complain.c (duplicate_rule_directive): Here.
* tests/actions.at (Invalid uses of %empty): Check it.
2019-01-17 18:09:38 +01:00
Akim Demaille d5d148630a fixits: fix warnings about duplicates
* src/complain.c (duplicate_directive): Fix the complaint level.
* tests/input.at: Adjust.
2019-01-17 18:09:32 +01:00
Akim Demaille b443932991 diagnostics: properly indent the "previous declaration" message
* src/complain.c (duplicate_directive, duplicate_rule_directive):
Here.
2019-01-16 08:40:47 +01:00
Akim Demaille f5a646c390 regen 2019-01-16 08:40:47 +01:00
Akim Demaille f038f0b12f style: rename some functions for consistency
"handle_" is the prefix used in scan-code.l for instance.

* src/parse-gram.y (do_error_verbose, do_name_prefix, do_require)
(do_skeleton, do_yacc):
Rename as...
(handle_error_verbose, handle_name_prefix, handle_require)
(handle_skeleton, handle_yacc):
these.
2019-01-16 08:40:47 +01:00
Akim Demaille b6b397b7f0 fixits: report duplicate %yacc directives
We should use -ffixit and --update to clean files with duplicate
directives.  And we should complain only once about duplicate obsolete
directives: keep only the "duplicate" warning.  Let's start with %yacc.

For instance on:

    %fixed-output_files
    %fixed-output-files
    %yacc
    %%
    exp:

This run of bison:

    $ bison /tmp/foo.y -u
    foo.y:1.1-19: warning: deprecated directive, use '%fixed-output-files' [-Wdeprecated]
     %fixed-output_files
     ^~~~~~~~~~~~~~~~~~~
    foo.y:2.1-19: warning: duplicate directive [-Wother]
     %fixed-output-files
     ^~~~~~~~~~~~~~~~~~~
    foo.y:1.1-19: previous declaration
     %fixed-output_files
     ^~~~~~~~~~~~~~~~~~~
    foo.y:3.1-5: warning: duplicate directive [-Wother]
     %yacc
     ^~~~~
    foo.y:1.1-19: previous declaration
     %fixed-output_files
     ^~~~~~~~~~~~~~~~~~~
    bison: file 'foo.y' was updated (backup: 'foo.y~')

gives:

    %fixed-output-files
    %%
    exp:

* src/location.h, src/location.c (location_empty): New.
* src/complain.h, src/complain.c (duplicate_directive): New.

* src/getargs.h, src/getargs.c (yacc_flag): Instead of a Boolean, be
the location of the definition.
Update dependencies.

* src/scan-gram.l (%yacc, %fixed-output-files): Move the handling of
its warnings to...
* src/parse-gram.y (do_yacc): This new function.

* tests/input.at (Deprecated Directives): Adjust expectations.
2019-01-16 08:40:39 +01:00
Akim Demaille 2c8fb4d126 style: rename duplicate_directive as duplicate_rule_directive
* src/complain.h, src/complain.c: here.
Adjust callers.
2019-01-16 07:59:25 +01:00
Akim Demaille 169fe80c7f fixits: suggest running --update if there are fixits
* src/fixits.h, src/fixits.c (fixits_empty): New.
* src/complain.c (deprecated_directive): Register the Wdeprecated
fixits only if -Wdeprecated was enabled, so that we don't apply
updates if the user didn't ask for them.
* src/main.c (main): If there were fixits, issue a warning suggesting
running with --update.
Free uniqstrs after the fixits, since the latter use the former.
* tests/headers.at, tests/input.at: Update expectations.
2019-01-16 07:59:16 +01:00
Akim Demaille b7e0d3131d fixits: avoid generating empty lines
* src/fixits.c (fixits_run): If erase the content of a line, also
erase the following \n.
* tests/input.at (Deprecated directives): Update expectations.
2019-01-16 06:55:47 +01:00
Akim Demaille a634aad9e6 configure: don't try to run C++ warnings on C
Reported by Derek Clegg.
https://lists.gnu.org/archive/html/bison-patches/2019-01/msg00066.html

* configure.ac: here.
2019-01-15 20:43:27 +01:00
Akim Demaille ad326ada91 c, c++: avoid implicit fall-throw
Reported by Derek Clegg.
http://lists.gnu.org/archive/html/bug-bison/2019-01/msg00004.html

* configure.ac (warn_common): Add -Wimplicit-fallthrough.
This does trigger failures in the test suite.
* data/skeletons/glr.c, data/skeletons/lalr1.cc,
* data/skeletons/yacc.c, tests/c++.at:
Make fall-throws explicit.
2019-01-15 18:07:00 +01:00
Akim Demaille a049509d04 c++: avoid -Wundefined-func-template warnings from clang
Reported by Derek Clegg.
http://lists.gnu.org/archive/html/bug-bison/2019-01/msg00006.html

Clang does not like this:

    template <typename D>
    struct basic_symbol : D
    {
      basic_symbol();
    };

    struct by_type {};

    struct symbol_type : basic_symbol<by_type>
    {
      symbol_type(){}
    };

It gives:

    $ clang++-mp-7.0 -Wundefined-func-template foo.cc -c
    foo.cc:11:3: warning: instantiation of function 'basic_symbol<by_type>::basic_symbol'
                 required here, but no definition is available [-Wundefined-func-template]
      symbol_type(){}
      ^
    foo.cc:4:3: note: forward declaration of template entity is here
      basic_symbol();
      ^
    foo.cc:11:3: note: add an explicit instantiation declaration to suppress this warning
                 if 'basic_symbol<by_type>::basic_symbol' is explicitly instantiated in
                 another translation unit
      symbol_type(){}
      ^
    1 warning generated.

The same applies for the basic_symbol's destructor and `clear()`.

* configure.ac (warn_cxx): Add -Wundefined-func-template.
This triggered one failure in the test suite:
* tests/headers.at (Sane headers): here, where we check that we can
compile the generated headers in other compilation units than the
parser's.
Add a variant type to make sure that basic_symbol and symbol_type are
properly generated in this case.
* data/skeletons/c++.m4 (basic_symbol): Inline the definitions of the
destructor and of `clear` in the class definition.
2019-01-15 07:10:29 +01:00
Akim Demaille 7c5e508b39 Revert the last two commits
They should not have been pushed, sorry about that.

This reverts
- commit 8575bd06ae.
- commit 55bf52860e.
2019-01-14 20:04:38 +01:00
Akim Demaille 55bf52860e c++: avoid warnings about extraneous semi-colons
Reported by Derek Clegg.

* configure.ac (warn_common): Add -Wextra-semi.
* data/skeletons/c++.m4: Remove extraneous semi-colon.
2019-01-14 19:57:37 +01:00
Akim Demaille 8575bd06ae WIP 2019-01-14 19:57:37 +01:00
Akim Demaille 7c63cc1f6b diagnostics: add fixit support for duplicate removal
* src/muscle-tab.c (muscle_percent_define_insert): Register a fixit
for duplicate removal.
* tests/input.at: Adjust expectations.
2019-01-14 19:57:37 +01:00
Akim Demaille 4a41a8ec51 regen 2019-01-14 19:57:37 +01:00
Akim Demaille ba469451d8 diagnostics: improve the accuracy for %error-verbose
Avoid duplicate warnings about %error-verbose, once for deprecation,
another for duplicate.  Keep only the duplicate warning for the second
occurrence of %error-verbose.

This will help removal fixits.

* src/scan-gram.l (%error-verbose): Return as a PERCENT_ERROR_VERBOSE
token.
* src/parse-gram.y (do_error_verbose): New.
Use it.
* src/muscle-tab.c (muscle_percent_variable_update): Handle pseudo
variables such as %error-verbose.
2019-01-14 19:57:37 +01:00
Akim Demaille 8580b268c3 diagnostics: avoid duplicate warnings for deprecated directives
Currently, on

    %define parser_class_name "Parser"
    %define parser_class_name "Parser"
    %%
    exp:;

we issue:

    foo.y:1.9-25: warning: deprecated directive, use '%define api.parser.class {Parser}' [-Wdeprecated]
     %define parser_class_name "Parser"
             ^~~~~~~~~~~~~~~~~
    foo.y:2.9-25: warning: deprecated directive, use '%define api.parser.class {Parser}' [-Wdeprecated]
     %define parser_class_name "Parser"
             ^~~~~~~~~~~~~~~~~
    foo.y:2.9-25: error: %define variable 'api.parser.class' redefined
     %define parser_class_name "Parser"
             ^~~~~~~~~~~~~~~~~
    foo.y:1.9-25:     previous definition
     %define parser_class_name "Parser"
             ^~~~~~~~~~~~~~~~~

Let's get rid of the second warning about the deprecated variable
parser_class_name.  This is noise, but it will also be a problem with
fixits for removing duplicates, as we will first generate the update,
and then it's too late to remove it: fixits do not edit the result of
previous fixits.

So generate this instead:

    foo.y:1.1-34: warning: deprecated directive, use '%define api.parser.class {Parser}' [-Wdeprecated]
     %define parser_class_name "Parser"
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    foo.y:2.1-34: error: %define variable 'api.parser.class' redefined
     %define parser_class_name "Parser"
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    foo.y:1.1-34:     previous definition
     %define parser_class_name "Parser"
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* src/muscle-tab.c (muscle_percent_variable_update): Pass the warning
to the caller, instead of issuing it.
(muscle_percent_define_insert): Issue this warning only if we don't
have to complain about a duplicate definition.
* tests/input.at: Adjust expectations.
2019-01-14 19:57:37 +01:00
Akim Demaille 41aaa8374c diagnostics: update the grammar file
Let's use the fixits to actually update the grammar files.

* src/getargs.h, src/getargs.c (update_flag): New.
* src/fixits.h, src/fixits.c (fixits_run): New.
* src/main.c (main): Invoke fixits_run when --update is passed.
* tests/input.at (Deprecated directives): Check --update.
2019-01-14 19:57:37 +01:00
Akim Demaille 79e79be298 diagnostics: improve accuracy for deprecated %define variables
* src/parse-gram.y: Use the location of the whole definition to record
the location of a %define variable, instead of just the name of the
variable.
Adjust tests.
2019-01-14 19:57:37 +01:00
Akim Demaille ffe2e4aaec diagnostics: keep the fixits
Introduce proper support for fixits, instead of just printing them on
demand.

* bootstrap.conf: We need gnulib's xlists.
* src/fixits.h, src/fixits.c: New.
* src/complain.c (deprecated_directive): Use fixits_register.
* src/main.c (main): Use fixits_free.
2019-01-14 19:57:37 +01:00
Akim Demaille dad14ec3e4 diagnostics: add -ffixit support for deprecated features
Issue directives for IDE/editors to fix the source file.
http://clang.llvm.org/docs/UsersManual.html#cmdoption-fdiagnostics-parseable-fixits

Do it for deprecated features.  For instance:

    $ cat foo.y
    %error-verbose

    %name-prefix = "foo"
    %name-prefix="bar"
    %define parser_class_name "Parser"

    %%
    exp:;

    $ LC_ALL=C ./_build/8d/tests/bison -ffixit /tmp/foo.yy
    /tmp/foo.yy:1.1-14: warning: deprecated directive, use '%define parse.error verbose' [-Wdeprecated]
     %error-verbose
     ^^^^^^^^^^^^^^
    fix-it:"/tmp/foo.yy":{1:1-1:15}:"%define parse.error verbose"
    /tmp/foo.yy:3.1-20: warning: deprecated directive, use '%define api.prefix {foo}' [-Wdeprecated]
     %name-prefix = "foo"
     ^^^^^^^^^^^^^^^^^^^^
    fix-it:"/tmp/foo.yy":{3:1-3:21}:"%define api.prefix {foo}"
    /tmp/foo.yy:4.1-18: warning: deprecated directive, use '%define api.prefix {bar}' [-Wdeprecated]
     %name-prefix="bar"
     ^^^^^^^^^^^^^^^^^^
    fix-it:"/tmp/foo.yy":{4:1-4:19}:"%define api.prefix {bar}"
    /tmp/foo.yy:5.9-25: warning: deprecated directive, use '%define api.parser.class {Parser}' [-Wdeprecated]
     %define parser_class_name "Parser"
             ^^^^^^^^^^^^^^^^^
    fix-it:"/tmp/foo.yy":{5:9-5:26}:"%define api.parser.class {Parser}"
    /tmp/foo.yy:5.9-25: error: %define variable 'api.parser.class' is not used
     %define parser_class_name "Parser"
             ^^^^^^^^^^^^^^^^^

* src/getargs.h, src/getargs.c (feature_fixit_parsable): New.
(feature_types, feature_args): Use it.
* src/complain.c (deprecated_directive): Use it.

* tests/input.at: Check it.
2019-01-14 19:57:37 +01:00
Akim Demaille a7ff1c75be diagnostics: prefer ^~~~ to ^^^^ to underline code
That's what both GCC and Clang do, and it is indeed much nicer to
read.  From:

    foo.y:1.1-14: warning: deprecated directive, use '%define parse.error verbose' [-Wdeprecated]
     %error-verbose
     ^^^^^^^^^^^^^^
    foo.y:4.1-20: warning: deprecated directive, use '%define api.prefix {foo}' [-Wdeprecated]
     %name-prefix = "foo"
     ^^^^^^^^^^^^^^^^^^^^

to:

    foo.y:1.1-14: warning: deprecated directive, use '%define parse.error verbose' [-Wdeprecated]
     %error-verbose
     ^~~~~~~~~~~~~~
    foo.y:4.1-20: warning: deprecated directive, use '%define api.prefix {foo}' [-Wdeprecated]
     %name-prefix = "foo"
     ^~~~~~~~~~~~~~~~~~~~

* src/location.c (location_caret): Use ^~~~.
Adjust tests expectations.
2019-01-14 19:57:37 +01:00
Akim Demaille 8c3a7687e4 regen 2019-01-14 19:57:37 +01:00
Akim Demaille 72c488aa62 diagnostics: improve them for %name-prefix
Currently the diagnostics for %name-prefix are not precise enough.  In
particular, they does not show that braces must be used instead of
quotes.

Before:

    foo.y:3.1-14: warning: deprecated directive, use '%define api.prefix' [-Wdeprecated]
     %name-prefix = "foo"
     ^^^^^^^^^^^^^^

After:

    foo.y:3.1-20: warning: deprecated directive, use '%define api.prefix {foo}' [-Wdeprecated]
     %name-prefix = "foo"
     ^^^^^^^^^^^^^^^^^^^^

To do this we need the value passed to %name-prefix, so move the
warning from the scanner to the parser.

Accuracy will be very important for the forthcoming changes.

* src/parse-gram.y (do_name_prefix): New.
(PERCENT_NAME_PREFIX): Have a semantic value: the raw source, with
possibly underscores, equal sign, and spaces.  This is used to provide
a more accurate message.  It does not take comments into account,
but...
* src/scan-gram.l (%name-prefix): Delegate the warnings to the parser.

* tests/headers.at, tests/input.at: Adjust expectations.
2019-01-14 19:57:37 +01:00
Akim Demaille a88f8117b0 diagnostics: style: avoid allocating memory when not needed
* src/muscle-tab.c (muscle_percent_variable_update): Avoid allocating
memory when it is not needed, which should be most of the time (when
there's no update to perform).
Adjust callers.
2019-01-14 19:57:37 +01:00
Akim Demaille 3551d51dd9 c++: avoid warnings about extraneous semi-colons
Reported by Derek Clegg.
http://lists.gnu.org/archive/html/bug-bison/2019-01/msg00005.html

* configure.ac (warn_cxx): Add -Wextra-semi.
* data/skeletons/c++.m4: Remove extraneous semi-colon.
2019-01-14 19:45:01 +01:00
Akim Demaille 38b17c36da style: minor changes
* src/muscle-tab.c: Sort alphabetically.
* src/scan-gram.l: Reduce scopes.
Initialize variables.
2019-01-13 12:48:42 +01:00
Akim Demaille f9db426de6 c++: beware of -Wshadow
This line:

    slice<stack_symbol_type, stack_type> slice (yystack_, yylen);

triggers warnings:

    parse.h:1790:11: note: shadowed declaration is here

Reported by Frank Heckenbach.
http://lists.gnu.org/archive/html/bug-bison/2019-01/msg00002.html

* configure.ac (warn_c): Move -Wshadow to...
(warn_common): here.
* data/skeletons/stack.hh (slice): Define as an inner class of stack.
* data/skeletons/lalr1.cc: Adjust.
Rename the variable as 'range' instead of 'slice'.
2019-01-13 12:26:58 +01:00
Akim Demaille c927c955c8 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2019-01-12 10:59:57 +01:00
44 changed files with 2202 additions and 1311 deletions
+1 -1
View File
@@ -1 +1 @@
3.2.2 3.2.90
+69
View File
@@ -1,5 +1,61 @@
GNU Bison NEWS GNU Bison NEWS
* Noteworthy changes in release 3.2.91 (2019-01-19) [beta]
** New features
*** Generation of fix-its for IDEs/Editors
When given the new option -ffixit (aka -fdiagnostics-parseable-fixits),
bison now generates machine readable editing instructions to fix some
issues. Currently, this is mostly limited to updating deprecated
directives and removing duplicates. For instance:
$ cat foo.y
%error-verbose
%define parser_class_name "Parser"
%define api.parser.class "Parser"
%%
exp:;
See the "fix-it:" lines below:
$ bison -ffixit foo.y
foo.y:1.1-14: warning: deprecated directive, use '%define parse.error verbose' [-Wdeprecated]
%error-verbose
^~~~~~~~~~~~~~
fix-it:"foo.y":{1:1-1:15}:"%define parse.error verbose"
foo.y:2.1-34: warning: deprecated directive, use '%define api.parser.class {Parser}' [-Wdeprecated]
%define parser_class_name "Parser"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fix-it:"foo.y":{2:1-2:35}:"%define api.parser.class {Parser}"
foo.y:3.1-33: error: %define variable 'api.parser.class' redefined
%define api.parser.class "Parser"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foo.y:2.1-34: previous definition
%define parser_class_name "Parser"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fix-it:"foo.y":{3:1-3:34}:""
foo.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
This uses the same output format as GCC and Clang.
*** Updating grammar files
Fixes can be applied on the fly. The previous example ends with the
suggestion to re-run bison with the option -u/--update, which results in a
cleaner grammar file.
$ bison --update foo.y
[...]
bison: file 'foo.y' was updated (backup: 'foo.y~')
$ cat foo.y
%define parse.error verbose
%define api.parser.class {Parser}
%%
exp:;
* Noteworthy changes in release 3.2.90 (2019-01-12) [beta] * Noteworthy changes in release 3.2.90 (2019-01-12) [beta]
** Backward incompatible changes ** Backward incompatible changes
@@ -9,6 +65,8 @@ GNU Bison NEWS
** Deprecated features ** Deprecated features
*** Deprecated directives
The %error-verbose directive is deprecated in favor of '%define The %error-verbose directive is deprecated in favor of '%define
parse.error verbose' since Bison 3.0, but no warning was issued. parse.error verbose' since Bison 3.0, but no warning was issued.
@@ -20,6 +78,17 @@ GNU Bison NEWS
@code{YYTOKENTYPE}, @code{yytokentype}, @code{YYSTYPE}, @code{YYLTYPE}, @code{YYTOKENTYPE}, @code{yytokentype}, @code{YYSTYPE}, @code{YYLTYPE},
etc. etc.
Users of Flex that move from '%name-prefix "xx"' to '%define api.prefix
{xx}' will typically have to update YY_DECL from
#define YY_DECL int xxlex (YYSTYPE *yylval, YYLTYPE *yylloc)
to
#define YY_DECL int xxlex (XXSTYPE *yylval, XXLTYPE *yylloc)
*** Deprecated %define variable names
The following variables, mostly related to parsers in Java, have been The following variables, mostly related to parsers in Java, have been
renamed for consistency. Backward compatibility is ensured, but upgrading renamed for consistency. Backward compatibility is ensured, but upgrading
is recommended. is recommended.
+6 -2
View File
@@ -17,7 +17,7 @@
# gnulib modules used by this package. # gnulib modules used by this package.
gnulib_modules=' gnulib_modules='
argmatch assert argmatch array-list assert
bitsetv bitsetv
calloc-posix close closeout config-h c-strcase calloc-posix close closeout config-h c-strcase
configmake configmake
@@ -26,7 +26,9 @@ gnulib_modules='
getopt-gnu getopt-gnu
gettext git-version-gen gitlog-to-changelog gettext git-version-gen gitlog-to-changelog
gpl-3.0 hash inttypes isnan javacomp-script gpl-3.0 hash inttypes isnan javacomp-script
javaexec-script ldexpl malloc-gnu javaexec-script
ldexpl
malloc-gnu
mbswidth mbswidth
non-recursive-gnulib-prefix-hack non-recursive-gnulib-prefix-hack
obstack obstack
@@ -36,6 +38,7 @@ gnulib_modules='
readme-release readme-release
realloc-posix realloc-posix
relocatable-prog relocatable-script relocatable-prog relocatable-script
rename
spawn-pipe stdbool stpcpy strdup-posix strerror strverscmp spawn-pipe stdbool stpcpy strdup-posix strerror strverscmp
timevar timevar
unistd unistd-safer unlink unlocked-io unistd unistd-safer unlink unlocked-io
@@ -44,6 +47,7 @@ gnulib_modules='
xalloc xalloc
xalloc-die xalloc-die
xconcat-filename xconcat-filename
xlist
xmemdup0 xmemdup0
xstrndup xstrndup
+5 -1
View File
@@ -48,7 +48,11 @@ while (<STDIN>)
# are strings and have the same syntax as on the command line. # are strings and have the same syntax as on the command line.
if ($dir_arg eq 'name[=value]') if ($dir_arg eq 'name[=value]')
{ {
$dir_arg = '@var{name} ["@var{value}"]'; # -D/-F do not add quotes to the argument.
$dir_arg =
$dir eq "%define"
? '@var{name} [@var{value}]'
: '@var{name} ["@var{value}"]';
} }
else else
{ {
+1
View File
@@ -160,6 +160,7 @@ exclude = \
$(foreach a,$(1),$(eval $(subst $$,$$$$,exclude_file_name_regexp--sc_$(a)))) $(foreach a,$(1),$(eval $(subst $$,$$$$,exclude_file_name_regexp--sc_$(a))))
$(call exclude, \ $(call exclude, \
bindtextdomain=^lib/main.c$$ \ bindtextdomain=^lib/main.c$$ \
cast_of_argument_to_free=^src/muscle-tab.c$$ \
preprocessor_indentation=^data/|^lib/|^src/parse-gram.[ch]$$ \ preprocessor_indentation=^data/|^lib/|^src/parse-gram.[ch]$$ \
program_name=^lib/main.c$$ \ program_name=^lib/main.c$$ \
prohibit_always-defined_macros=^data/skeletons/yacc.c$$ \ prohibit_always-defined_macros=^data/skeletons/yacc.c$$ \
+5 -3
View File
@@ -96,9 +96,11 @@ AM_CONDITIONAL([ENABLE_GCC_WARNINGS], [test "$enable_gcc_warnings" = yes])
if test "$enable_gcc_warnings" = yes; then if test "$enable_gcc_warnings" = yes; then
warn_common='-Wall -Wextra -Wno-sign-compare -Wcast-align warn_common='-Wall -Wextra -Wno-sign-compare -Wcast-align
-fparse-all-comments -Wdocumentation -fparse-all-comments -Wdocumentation
-Wformat -Wnull-dereference -Wpointer-arith -Wwrite-strings' -Wformat -Wimplicit-fallthrough -Wnull-dereference
warn_c='-Wbad-function-cast -Wshadow -Wstrict-prototypes' -Wpointer-arith -Wshadow
warn_cxx='-Wnoexcept' -Wwrite-strings'
warn_c='-Wbad-function-cast -Wstrict-prototypes'
warn_cxx='-Wextra-semi -Wnoexcept -Wundefined-func-template'
# Warnings for the test suite only. # Warnings for the test suite only.
# #
# -fno-color-diagnostics: Clang's use of colors in the error # -fno-color-diagnostics: Clang's use of colors in the error
+26 -36
View File
@@ -260,7 +260,10 @@ m4_define([b4_symbol_type_define],
typedef Base super_type; typedef Base super_type;
/// Default constructor. /// Default constructor.
basic_symbol (); basic_symbol ()
: value ()]b4_locations_if([
, location ()])[
{}
#if 201103L <= YY_CPLUSPLUS #if 201103L <= YY_CPLUSPLUS
/// Move constructor. /// Move constructor.
@@ -282,10 +285,29 @@ m4_define([b4_symbol_type_define],
YY_RVREF (location_type) l])[); YY_RVREF (location_type) l])[);
]])[ ]])[
/// Destroy the symbol. /// Destroy the symbol.
~basic_symbol (); ~basic_symbol ()
{
clear ();
}
/// Destroy contents, and record that is empty. /// Destroy contents, and record that is empty.
void clear (); void clear ()
{]b4_variant_if([[
// User destructor.
symbol_number_type yytype = this->type_get ();
basic_symbol<Base>& yysym = *this;
(void) yysym;
switch (yytype)
{
]b4_symbol_foreach([b4_symbol_destructor])dnl
[ default:
break;
}
// Type destructor.
]b4_symbol_variant([[yytype]], [[value]], [[template destroy]])])[
Base::clear ();
}
/// Whether empty. /// Whether empty.
bool empty () const YY_NOEXCEPT; bool empty () const YY_NOEXCEPT;
@@ -352,7 +374,7 @@ m4_define([b4_symbol_type_define],
typedef basic_symbol<by_type> super_type; typedef basic_symbol<by_type> super_type;
/// Empty symbol. /// Empty symbol.
symbol_type () {}; symbol_type () {}
/// Constructor for valueless symbols, and symbols from each type. /// Constructor for valueless symbols, and symbols from each type.
]b4_type_foreach([_b4_token_constructor_define])dnl ]b4_type_foreach([_b4_token_constructor_define])dnl
@@ -365,12 +387,6 @@ m4_define([b4_symbol_type_define],
# Provide the implementation needed by the public types. # Provide the implementation needed by the public types.
m4_define([b4_public_types_define], m4_define([b4_public_types_define],
[[ // basic_symbol. [[ // basic_symbol.
template <typename Base>
]b4_parser_class[::basic_symbol<Base>::basic_symbol ()
: value ()]b4_locations_if([
, location ()])[
{}
#if 201103L <= YY_CPLUSPLUS #if 201103L <= YY_CPLUSPLUS
template <typename Base> template <typename Base>
]b4_parser_class[::basic_symbol<Base>::basic_symbol (basic_symbol&& that) ]b4_parser_class[::basic_symbol<Base>::basic_symbol (basic_symbol&& that)
@@ -416,32 +432,6 @@ m4_define([b4_public_types_define],
(void) v; (void) v;
]b4_symbol_variant([this->type_get ()], [value], [YY_MOVE_OR_COPY], [YY_MOVE (v)])])[}]])[ ]b4_symbol_variant([this->type_get ()], [value], [YY_MOVE_OR_COPY], [YY_MOVE (v)])])[}]])[
template <typename Base>
]b4_parser_class[::basic_symbol<Base>::~basic_symbol ()
{
clear ();
}
template <typename Base>
void
]b4_parser_class[::basic_symbol<Base>::clear ()
{]b4_variant_if([[
// User destructor.
symbol_number_type yytype = this->type_get ();
basic_symbol<Base>& yysym = *this;
(void) yysym;
switch (yytype)
{
]b4_symbol_foreach([b4_symbol_destructor])dnl
[ default:
break;
}
// Type destructor.
]b4_symbol_variant([[yytype]], [[value]], [[template destroy]])])[
Base::clear ();
}
template <typename Base> template <typename Base>
bool bool
]b4_parser_class[::basic_symbol<Base>::empty () const YY_NOEXCEPT ]b4_parser_class[::basic_symbol<Base>::empty () const YY_NOEXCEPT
+4 -1
View File
@@ -590,7 +590,10 @@ yytnamerr (char *yyres, const char *yystr)
case '\\': case '\\':
if (*++yyp != '\\') if (*++yyp != '\\')
goto do_not_strip_quotes; goto do_not_strip_quotes;
/* Fall through. */ else
goto append;
append:
default: default:
if (yyres) if (yyres)
yyres[yyn] = *yyp; yyres[yyn] = *yyp;
+6 -3
View File
@@ -532,7 +532,10 @@ m4_if(b4_prefix, [yy], [],
case '\\': case '\\':
if (*++yyp != '\\') if (*++yyp != '\\')
goto do_not_strip_quotes; goto do_not_strip_quotes;
// Fall through. else
goto append;
append:
default: default:
yyr += *yyp; yyr += *yyp;
break; break;
@@ -896,8 +899,8 @@ b4_dollar_popdef])[]dnl
[ [
// Default location. // Default location.
{ {
slice<stack_symbol_type, stack_type> slice (yystack_, yylen); stack_type::slice range (yystack_, yylen);
YYLLOC_DEFAULT (yylhs.location, slice, yylen); YYLLOC_DEFAULT (yylhs.location, range, yylen);
yyerror_range[1].location = yylhs.location; yyerror_range[1].location = yylhs.location;
}]])[ }]])[
+20 -21
View File
@@ -122,33 +122,32 @@ m4_define([b4_stack_define],
return seq_.rend (); return seq_.rend ();
} }
/// Present a slice of the top of a stack.
class slice
{
public:
slice (const stack& stack, int range)
: stack_ (stack)
, range_ (range)
{}
const T&
operator[] (int i) const
{
return stack_[range_ - i];
}
private:
const stack& stack_;
int range_;
};
private: private:
stack (const stack&); stack (const stack&);
stack& operator= (const stack&); stack& operator= (const stack&);
/// The wrapped container. /// The wrapped container.
S seq_; S seq_;
}; };
/// Present a slice of the top of a stack.
template <typename T, typename S = stack<T> >
class slice
{
public:
slice (const S& stack, int range)
: stack_ (stack)
, range_ (range)
{}
const T&
operator[] (int i) const
{
return stack_[range_ - i];
}
private:
const S& stack_;
int range_;
};
]]) ]])
m4_ifdef([b4_stack_file], m4_ifdef([b4_stack_file],
+4 -1
View File
@@ -1066,7 +1066,10 @@ yytnamerr (char *yyres, const char *yystr)
case '\\': case '\\':
if (*++yyp != '\\') if (*++yyp != '\\')
goto do_not_strip_quotes; goto do_not_strip_quotes;
/* Fall through. */ else
goto append;
append:
default: default:
if (yyres) if (yyres)
yyres[yyn] = *yyp; yyres[yyn] = *yyp;
+134 -20
View File
@@ -4278,16 +4278,16 @@ final action does not use @code{$3}). Bison reports these errors when the
Bison}): Bison}):
@example @example
$ bison -Wmidrule-value mid.y $ @kbd{bison -Wmidrule-value mid.y}
@group @group
mid.y:2.6-13: warning: unset value: $$ mid.y:2.6-13: warning: unset value: $$
exp: @{ a(); @} "b" @{ $$ = c(); @} @{ d(); @} "e" @{ f = $1; @}; exp: @{ a(); @} "b" @{ $$ = c(); @} @{ d(); @} "e" @{ f = $1; @};
^^^^^^^^ ^~~~~~~~
@end group @end group
@group @group
mid.y:2.19-31: warning: unused value: $3 mid.y:2.19-31: warning: unused value: $3
exp: @{ a(); @} "b" @{ $$ = c(); @} @{ d(); @} "e" @{ f = $1; @}; exp: @{ a(); @} "b" @{ $$ = c(); @} @{ d(); @} "e" @{ f = $1; @};
^^^^^^^^^^^^^ ^~~~~~~~~~~~~
@end group @end group
@end example @end example
@@ -6650,6 +6650,28 @@ For example, if you use @samp{%define api.prefix @{c@}}, the names become
@code{cparse}, @code{clex}, @dots{}, @code{CSTYPE}, @code{CLTYPE}, and so @code{cparse}, @code{clex}, @dots{}, @code{CSTYPE}, @code{CLTYPE}, and so
on. on.
Users of Flex must update the signature of the generated @code{yylex}
function. Since the Flex scanner usually includes the generated header of
the parser (to get the definitions of the tokens, etc.), the most convenient
way is to insert the declaration of @code{yylex} in the @code{provides}
section:
@example
%define api.prefix @{c@}
// Emitted in the header file, after the definition of YYSTYPE.
%code provides
@{
// Tell Flex the expected prototype of yylex.
#define YY_DECL \
int clex (CSTYPE *yylval, CLTYPE *yylloc)
// Declare the scanner.
YY_DECL;
@}
@end example
@sp 1
The @code{%define} variable @code{api.prefix} works in two different ways. The @code{%define} variable @code{api.prefix} works in two different ways.
In the implementation file, it works by adding macro definitions to the In the implementation file, it works by adding macro definitions to the
beginning of the parser implementation file, defining @code{yyparse} as beginning of the parser implementation file, defining @code{yyparse} as
@@ -9309,7 +9331,7 @@ calc.y: warning: 1 nonterminal useless in grammar [-Wother]
calc.y: warning: 1 rule useless in grammar [-Wother] calc.y: warning: 1 rule useless in grammar [-Wother]
calc.y:19.1-7: warning: nonterminal useless in grammar: useless [-Wother] calc.y:19.1-7: warning: nonterminal useless in grammar: useless [-Wother]
useless: STR; useless: STR;
^^^^^^^ ^~~~~~~
calc.y: warning: 7 shift/reduce conflicts [-Wconflicts-sr] calc.y: warning: 7 shift/reduce conflicts [-Wconflicts-sr]
@end example @end example
@@ -9842,12 +9864,12 @@ Used to output an xhtml enhancement of the @samp{.output} file.
Sample usage (requires @command{xsltproc}): Sample usage (requires @command{xsltproc}):
@example @example
$ bison -x gr.y $ @kbd{bison -x gr.y}
@group @group
$ bison --print-datadir $ @kbd{bison --print-datadir}
/usr/local/share/bison /usr/local/share/bison
@end group @end group
$ xsltproc /usr/local/share/bison/xslt/xml2xhtml.xsl gr.xml >gr.html $ @kbd{xsltproc /usr/local/share/bison/xslt/xml2xhtml.xsl gr.xml >gr.html}
@end example @end example
@c ================================================= Tracing @c ================================================= Tracing
@@ -10247,6 +10269,43 @@ Print the name of the directory containing locale-dependent data.
@item --print-datadir @item --print-datadir
Print the name of the directory containing skeletons and XSLT. Print the name of the directory containing skeletons and XSLT.
@item -u
@item --update
Update the grammar file (remove duplicates, update deprecated directives,
etc.). Leaves a backup of the original file with a @code{~} appended. For
instance:
@example
@group
$ @kbd{cat foo.y}
%error-verbose
%define parse.error verbose
%%
exp:;
@end group
@group
$ @kbd{bison -u foo.y}
foo.y:1.1-14: warning: deprecated directive, use '%define parse.error verbose' [-Wdeprecated]
%error-verbose
^~~~~~~~~~~~~~
foo.y:2.1-27: error: %define variable 'parse.error' redefined
%define parse.error verbose
^~~~~~~~~~~~~~~~~~~~~~~~~~~
foo.y:1.1-14: previous definition
%error-verbose
^~~~~~~~~~~~~~
bison: file 'foo.y' was updated (backup: 'foo.y~')
@end group
@group
$ @kbd{cat foo.y}
%define parse.error verbose
%%
exp:;
@end group
@end example
See the documentation of @option{--feature=fixit} below for more details.
@item -y @item -y
@itemx --yacc @itemx --yacc
Act more like the traditional Yacc command. This can cause different Act more like the traditional Yacc command. This can cause different
@@ -10353,17 +10412,17 @@ Bison reports:
@group @group
warning: useless precedence and associativity for "=" warning: useless precedence and associativity for "="
%nonassoc "=" %nonassoc "="
^^^ ^~~
@end group @end group
@group @group
warning: useless associativity for "*", use %precedence warning: useless associativity for "*", use %precedence
%left "*" %left "*"
^^^ ^~~
@end group @end group
@group @group
warning: useless precedence for "(" warning: useless precedence for "("
%precedence "(" %precedence "("
^^^ ^~~
@end group @end group
@end example @end example
@@ -10412,8 +10471,8 @@ the following commands are @emph{not} equivalent, as the first will not treat
S/R conflicts as errors. S/R conflicts as errors.
@example @example
$ bison -Werror=yacc,conflicts-sr input.y $ @kbd{bison -Werror=yacc,conflicts-sr input.y}
$ bison -Werror=yacc,error=conflicts-sr input.y $ @kbd{bison -Werror=yacc,error=conflicts-sr input.y}
@end example @end example
@item -Wno-error @item -Wno-error
@@ -10449,27 +10508,27 @@ When invoked with @option{-fcaret} (or nothing), Bison will report:
@group @group
in.y:3.20-23: error: ambiguous reference: '$exp' in.y:3.20-23: error: ambiguous reference: '$exp'
exp: exp '+' exp @{ $exp = $1 + $2; @}; exp: exp '+' exp @{ $exp = $1 + $2; @};
^^^^ ^~~~
@end group @end group
@group @group
in.y:3.1-3: refers to: $exp at $$ in.y:3.1-3: refers to: $exp at $$
exp: exp '+' exp @{ $exp = $1 + $2; @}; exp: exp '+' exp @{ $exp = $1 + $2; @};
^^^ ^~~
@end group @end group
@group @group
in.y:3.6-8: refers to: $exp at $1 in.y:3.6-8: refers to: $exp at $1
exp: exp '+' exp @{ $exp = $1 + $2; @}; exp: exp '+' exp @{ $exp = $1 + $2; @};
^^^ ^~~
@end group @end group
@group @group
in.y:3.14-16: refers to: $exp at $3 in.y:3.14-16: refers to: $exp at $3
exp: exp '+' exp @{ $exp = $1 + $2; @}; exp: exp '+' exp @{ $exp = $1 + $2; @};
^^^ ^~~
@end group @end group
@group @group
in.y:3.32-33: error: $2 of 'exp' has no declared type in.y:3.32-33: error: $2 of 'exp' has no declared type
exp: exp '+' exp @{ $exp = $1 + $2; @}; exp: exp '+' exp @{ $exp = $1 + $2; @};
^^ ^~
@end group @end group
@end example @end example
@@ -10487,6 +10546,61 @@ in.y:3.32-33: error: $2 of exp has no declared type
This option is activated by default. This option is activated by default.
@item fixit
@itemx diagnostics-parseable-fixits
Show machine-readable fixes, in a manner similar to GCC's and Clang's
@option{-fdiagnostics-parseable-fixits}.
Fix-its are generated for duplicate directives:
@example
@group
$ @kbd{cat foo.y}
%define api.prefix @{foo@}
%define api.prefix @{bar@}
%%
exp:;
@end group
@group
$ @kbd{bison -ffixit foo.y}
foo.y:2.1-24: error: %define variable 'api.prefix' redefined
%define api.prefix @{bar@}
^~~~~~~~~~~~~~~~~~~~~~~~
foo.y:1.1-24: previous definition
%define api.prefix @{foo@}
^~~~~~~~~~~~~~~~~~~~~~~~
fix-it:"foo.y":@{2:1-2:25@}:""
foo.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
@end group
@end example
They are also generated to update deprecated directives, unless
@option{-Wno-deprecated} was given:
@example
@group
$ @kbd{cat /tmp/foo.yy}
%error-verbose
%name-prefix "foo"
%%
exp:;
@end group
@group
$ @kbd{bison foo.y}
foo.y:1.1-14: warning: deprecated directive, use '%define parse.error verbose' [-Wdeprecated]
%error-verbose
^~~~~~~~~~~~~~
foo.y:2.1-18: warning: deprecated directive, use '%define api.prefix @{foo@}' [-Wdeprecated]
%name-prefix "foo"
^~~~~~~~~~~~~~~~~~
foo.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
@end group
@end example
The fix-its are applied by @command{bison} itself when given the option
@option{-u}/@option{--update}. See its documentation above.
@end table @end table
@end table @end table
@@ -10926,10 +11040,10 @@ int main ()
Compile, and run! Compile, and run!
@example @example
$ bison simple.yy -o simple.cc $ @kbd{bison simple.yy -o simple.cc}
$ g++ -std=c++14 simple.cc -o simple $ @kbd{g++ -std=c++14 simple.cc -o simple}
@group @group
$ ./simple $ @kbd{./simple}
@{I have three numbers for you., 1, 2, 3, And that's all!@} @{I have three numbers for you., 1, 2, 3, And that's all!@}
@end group @end group
@end example @end example
+45 -36
View File
@@ -8,6 +8,10 @@
/alignof.h /alignof.h
/alloca.h /alloca.h
/alloca.in.h /alloca.in.h
/allocator.c
/allocator.h
/areadlink.c
/areadlink.h
/arg-nonnull.h /arg-nonnull.h
/argmatch.c /argmatch.c
/argmatch.h /argmatch.h
@@ -18,6 +22,11 @@
/binary-io.h /binary-io.h
/bitrotate.c /bitrotate.c
/bitrotate.h /bitrotate.h
/bitset.c
/bitset.h
/bitset/
/bitsetv.c
/bitsetv.h
/c++defs.h /c++defs.h
/c-ctype.c /c-ctype.c
/c-ctype.h /c-ctype.h
@@ -26,6 +35,9 @@
/c-strcaseeq.h /c-strcaseeq.h
/c-strncasecmp.c /c-strncasecmp.c
/calloc.c /calloc.c
/canonicalize-lgpl.c
/careadlinkat.c
/careadlinkat.h
/charset.alias /charset.alias
/cloexec.c /cloexec.c
/cloexec.h /cloexec.h
@@ -78,6 +90,8 @@
/fseterr.h /fseterr.h
/fstat.c /fstat.c
/getdtablesize.c /getdtablesize.c
/gethrxtime.c
/gethrxtime.h
/getopt-cdefs.in.h /getopt-cdefs.in.h
/getopt-core.h /getopt-core.h
/getopt-ext.h /getopt-ext.h
@@ -90,7 +104,16 @@
/getopt_int.h /getopt_int.h
/getprogname.c /getprogname.c
/getprogname.h /getprogname.h
/getrusage.c
/gettext.h /gettext.h
/gettime.c
/gettimeofday.c
/gl_array_list.c
/gl_array_list.h
/gl_list.c
/gl_list.h
/gl_xlist.c
/gl_xlist.h
/gnulib.mk /gnulib.mk
/hard-locale.c /hard-locale.c
/hard-locale.h /hard-locale.h
@@ -112,6 +135,8 @@
/limits.in.h /limits.in.h
/localcharset.c /localcharset.c
/localcharset.h /localcharset.h
/localtime-buffer.c
/localtime-buffer.h
/lstat.c /lstat.c
/malloc.c /malloc.c
/malloca.c /malloca.c
@@ -150,17 +175,23 @@
/printf.c /printf.c
/progname.c /progname.c
/progname.h /progname.h
/progreloc.c
/quote.h /quote.h
/quotearg.c /quotearg.c
/quotearg.h /quotearg.h
/raise.c /raise.c
/rawmemchr.c /rawmemchr.c
/rawmemchr.valgrind /rawmemchr.valgrind
/readlink.c
/realloc.c /realloc.c
/ref-add.sed /ref-add.sed
/ref-del.sed /ref-del.sed
/relocatable.c
/relocatable.h
/relocwrapper.c
/sched.h /sched.h
/sched.in.h /sched.in.h
/setenv.c
/sig-handler.c /sig-handler.c
/sig-handler.h /sig-handler.h
/sigaction.c /sigaction.c
@@ -190,6 +221,8 @@
/spawnp.c /spawnp.c
/sprintf.c /sprintf.c
/stamp-h1 /stamp-h1
/stat-time.c
/stat-time.h
/stat-w32.c /stat-w32.c
/stat-w32.h /stat-w32.h
/stat.c /stat.c
@@ -223,13 +256,20 @@
/strverscmp.c /strverscmp.c
/sys /sys
/sys_ioctl.in.h /sys_ioctl.in.h
/sys_resource.in.h
/sys_socket.in.h /sys_socket.in.h
/sys_stat.in.h /sys_stat.in.h
/sys_time.in.h
/sys_times.in.h
/sys_types.in.h /sys_types.in.h
/sys_wait.in.h /sys_wait.in.h
/sysexits.in.h /sysexits.in.h
/time.h /time.h
/time.in.h /time.in.h
/timespec.c
/timespec.h
/timevar.c
/timevar.h
/unistd--.h /unistd--.h
/unistd-safer.h /unistd-safer.h
/unistd.c /unistd.c
@@ -267,45 +307,14 @@
/xmalloc.c /xmalloc.c
/xmemdup0.c /xmemdup0.c
/xmemdup0.h /xmemdup0.h
/xreadlink.c
/xreadlink.h
/xsize.c /xsize.c
/xsize.h /xsize.h
/xstrndup.c /xstrndup.c
/xstrndup.h /xstrndup.h
/stat-time.c
/stat-time.h
/timevar.c
/timevar.h
/sys_time.in.h
/sys_times.in.h
/gethrxtime.c
/gethrxtime.h
/getrusage.c
/gettime.c
/gettimeofday.c
/localtime-buffer.c
/localtime-buffer.h
/sys_resource.in.h
/timespec.c
/timespec.h
/xtime.c /xtime.c
/xtime.h /xtime.h
/bitset.c /rename.c
/bitset.h /rmdir.c
/bitset/ /same-inode.h
/bitsetv.c
/bitsetv.h
/allocator.c
/allocator.h
/areadlink.c
/areadlink.h
/canonicalize-lgpl.c
/careadlinkat.c
/careadlinkat.h
/progreloc.c
/readlink.c
/relocatable.c
/relocatable.h
/relocwrapper.c
/setenv.c
/xreadlink.c
/xreadlink.h
+1
View File
@@ -1,6 +1,7 @@
src/complain.c src/complain.c
src/conflicts.c src/conflicts.c
src/files.c src/files.c
src/fixits.c
src/getargs.c src/getargs.c
src/gram.c src/gram.c
src/graphviz.c src/graphviz.c
+20 -1
View File
@@ -28,6 +28,7 @@
#include "complain.h" #include "complain.h"
#include "files.h" #include "files.h"
#include "fixits.h"
#include "getargs.h" #include "getargs.h"
#include "quote.h" #include "quote.h"
@@ -393,6 +394,9 @@ deprecated_directive (location const *loc, char const *old, char const *upd)
complain (loc, Wdeprecated, complain (loc, Wdeprecated,
_("deprecated directive: %s, use %s"), _("deprecated directive: %s, use %s"),
quote (old), quote_n (1, upd)); quote (old), quote_n (1, upd));
/* Register updates only if -Wdeprecated is enabled. */
if (warnings_flag[warning_deprecated] != severity_disabled)
fixits_register (loc, upd);
} }
void void
@@ -400,7 +404,22 @@ duplicate_directive (char const *directive,
location first, location second) location first, location second)
{ {
unsigned i = 0; unsigned i = 0;
complain (&second, complaint, _("only one %s allowed per rule"), directive); if (feature_flag & feature_caret)
complain_indent (&second, Wother, &i, _("duplicate directive"));
else
complain_indent (&second, Wother, &i, _("duplicate directive: %s"), quote (directive));
i += SUB_INDENT;
complain_indent (&first, Wother, &i, _("previous declaration"));
fixits_register (&second, "");
}
void
duplicate_rule_directive (char const *directive,
location first, location second)
{
unsigned i = 0;
complain_indent (&second, complaint, &i, _("only one %s allowed per rule"), directive);
i += SUB_INDENT; i += SUB_INDENT;
complain_indent (&first, complaint, &i, _("previous declaration")); complain_indent (&first, complaint, &i, _("previous declaration"));
fixits_register (&second, "");
} }
+5 -1
View File
@@ -126,10 +126,14 @@ void bison_directive (location const *loc, char const *directive);
void deprecated_directive (location const *loc, void deprecated_directive (location const *loc,
char const *obsolete, char const *updated); char const *obsolete, char const *updated);
/** Report a repeated directive for a rule. */ /** Report a repeated directive. */
void duplicate_directive (char const *directive, void duplicate_directive (char const *directive,
location first, location second); location first, location second);
/** Report a repeated directive for a rule. */
void duplicate_rule_directive (char const *directive,
location first, location second);
/** Warnings treated as errors shouldn't stop the execution as regular /** Warnings treated as errors shouldn't stop the execution as regular
errors should (because due to their nature, it is safe to go errors should (because due to their nature, it is safe to go
on). Thus, there are three possible execution statuses. */ on). Thus, there are three possible execution statuses. */
+24 -31
View File
@@ -43,7 +43,9 @@
char const *spec_outfile = NULL; /* for -o. */ char const *spec_outfile = NULL; /* for -o. */
char const *spec_file_prefix = NULL; /* for -b. */ char const *spec_file_prefix = NULL; /* for -b. */
location spec_file_prefix_loc = EMPTY_LOCATION_INIT;
char const *spec_name_prefix = NULL; /* for -p. */ char const *spec_name_prefix = NULL; /* for -p. */
location spec_name_prefix_loc = EMPTY_LOCATION_INIT;
char *spec_verbose_file = NULL; /* for --verbose. */ char *spec_verbose_file = NULL; /* for --verbose. */
char *spec_graph_file = NULL; /* for -g. */ char *spec_graph_file = NULL; /* for -g. */
char *spec_xml_file = NULL; /* for -x. */ char *spec_xml_file = NULL; /* for -x. */
@@ -115,14 +117,12 @@ concat2 (char const *str1, char const *str2)
FILE * FILE *
xfopen (const char *name, const char *mode) xfopen (const char *name, const char *mode)
{ {
FILE *ptr; FILE *res = fopen_safer (name, mode);
if (!res)
ptr = fopen_safer (name, mode);
if (!ptr)
error (EXIT_FAILURE, get_errno (), error (EXIT_FAILURE, get_errno (),
_("%s: cannot open"), quotearg_colon (name)); _("%s: cannot open"), quotearg_colon (name));
return ptr; return res;
} }
/*-------------------------------------------------------------. /*-------------------------------------------------------------.
@@ -243,19 +243,18 @@ file_name_split (const char *file_name,
} }
} }
/* Compute ALL_BUT_EXT and ALL_BUT_TAB_EXT from SPEC_OUTFILE or
GRAMMAR_FILE.
The precise -o name will be used for FTABLE. For other output
files, remove the ".c" or ".tab.c" suffix. */
static void static void
compute_file_name_parts (void) compute_file_name_parts (void)
{ {
const char *base, *tab, *ext;
/* Compute ALL_BUT_EXT and ALL_BUT_TAB_EXT from SPEC_OUTFILE
or GRAMMAR_FILE.
The precise -o name will be used for FTABLE. For other output
files, remove the ".c" or ".tab.c" suffix. */
if (spec_outfile) if (spec_outfile)
{ {
const char *base, *tab, *ext;
file_name_split (spec_outfile, &base, &tab, &ext); file_name_split (spec_outfile, &base, &tab, &ext);
dir_prefix = xstrndup (spec_outfile, base - spec_outfile); dir_prefix = xstrndup (spec_outfile, base - spec_outfile);
@@ -275,6 +274,7 @@ compute_file_name_parts (void)
} }
else else
{ {
const char *base, *tab, *ext;
file_name_split (grammar_file, &base, &tab, &ext); file_name_split (grammar_file, &base, &tab, &ext);
if (spec_file_prefix) if (spec_file_prefix)
@@ -285,7 +285,7 @@ compute_file_name_parts (void)
last_component (spec_file_prefix) - spec_file_prefix); last_component (spec_file_prefix) - spec_file_prefix);
all_but_tab_ext = xstrdup (spec_file_prefix); all_but_tab_ext = xstrdup (spec_file_prefix);
} }
else if (yacc_flag) else if (! location_empty (yacc_loc))
{ {
/* If --yacc, then the output is 'y.tab.c'. */ /* If --yacc, then the output is 'y.tab.c'. */
dir_prefix = xstrdup (""); dir_prefix = xstrdup ("");
@@ -306,7 +306,7 @@ compute_file_name_parts (void)
all_but_ext = xstrdup (all_but_tab_ext); all_but_ext = xstrdup (all_but_tab_ext);
/* Compute the extensions from the grammar file name. */ /* Compute the extensions from the grammar file name. */
if (ext && !yacc_flag) if (ext && location_empty (yacc_loc))
compute_exts_from_gf (ext); compute_exts_from_gf (ext);
} }
} }
@@ -374,16 +374,13 @@ output_file_name_check (char **file_name, bool source)
conflict = true; conflict = true;
} }
else else
{ for (int i = 0; i < generated_files_size; i++)
int i; if (STREQ (generated_files[i].name, *file_name))
for (i = 0; i < generated_files_size; i++) {
if (STREQ (generated_files[i].name, *file_name)) complain (NULL, Wother, _("conflicting outputs to file %s"),
{ quote (generated_files[i].name));
complain (NULL, Wother, _("conflicting outputs to file %s"), conflict = true;
quote (generated_files[i].name)); }
conflict = true;
}
}
if (conflict) if (conflict)
{ {
free (*file_name); free (*file_name);
@@ -401,8 +398,7 @@ output_file_name_check (char **file_name, bool source)
void void
unlink_generated_sources (void) unlink_generated_sources (void)
{ {
int i; for (int i = 0; i < generated_files_size; i++)
for (i = 0; i < generated_files_size; i++)
if (generated_files[i].is_source) if (generated_files[i].is_source)
/* Ignore errors. The file might not even exist. */ /* Ignore errors. The file might not even exist. */
unlink (generated_files[i].name); unlink (generated_files[i].name);
@@ -418,10 +414,7 @@ output_file_names_free (void)
free (spec_defines_file); free (spec_defines_file);
free (parser_file_name); free (parser_file_name);
free (dir_prefix); free (dir_prefix);
{ for (int i = 0; i < generated_files_size; i++)
int i; free (generated_files[i].name);
for (i = 0; i < generated_files_size; i++)
free (generated_files[i].name);
}
free (generated_files); free (generated_files);
} }
+4 -1
View File
@@ -21,6 +21,7 @@
#ifndef FILES_H_ #ifndef FILES_H_
# define FILES_H_ # define FILES_H_
# include "location.h"
# include "uniqstr.h" # include "uniqstr.h"
/* File name specified with -o for the output file, or 0 if no -o. */ /* File name specified with -o for the output file, or 0 if no -o. */
@@ -31,9 +32,11 @@ extern char *parser_file_name;
/* Symbol prefix specified with -p, or 0 if no -p. */ /* Symbol prefix specified with -p, or 0 if no -p. */
extern const char *spec_name_prefix; extern const char *spec_name_prefix;
extern location spec_name_prefix_loc;
/* File name prefix specified with -b, or 0 if no -b. */ /* File name prefix specified with -b, or 0 if no -b. */
extern char const *spec_file_prefix; extern char const *spec_file_prefix;
extern location spec_file_prefix_loc;
/* --verbose. */ /* --verbose. */
extern char *spec_verbose_file; extern char *spec_verbose_file;
@@ -55,7 +58,7 @@ extern char *dir_prefix;
and therefore GCC warns about a name clash. */ and therefore GCC warns about a name clash. */
extern uniqstr grammar_file; extern uniqstr grammar_file;
/* The current file name. Might change with %include, or with #line. */ /* The current file name. Might change with #line. */
extern uniqstr current_file; extern uniqstr current_file;
/* The computed base for output file names. */ /* The computed base for output file names. */
+212
View File
@@ -0,0 +1,212 @@
/* Support for fixing grammar files.
Copyright (C) 2019 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include "fixits.h"
#include "system.h"
#include "error.h"
#include "get-errno.h"
#include "getargs.h"
#include "gl_array_list.h"
#include "gl_xlist.h"
#include "progname.h"
#include "quote.h"
#include "quotearg.h"
#include "vasnprintf.h"
#include "files.h"
typedef struct
{
location location;
char *fix;
} fixit;
gl_list_t fixits = NULL;
static fixit *
fixit_new (location const *loc, char const* fix)
{
fixit *res = xmalloc (sizeof *res);
res->location = *loc;
res->fix = xstrdup (fix);
return res;
}
static void
fixit_free (fixit *f)
{
free (f->fix);
free (f);
}
/* GCC and Clang follow the same pattern.
https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Message-Formatting-Options.html
http://clang.llvm.org/docs/UsersManual.html#cmdoption-fdiagnostics-parseable-fixits */
static void
fixit_print (fixit const *f, FILE *out)
{
fprintf (out, "fix-it:%s:{%d:%d-%d:%d}:%s\n",
quotearg_n_style (1, c_quoting_style, f->location.start.file),
f->location.start.line, f->location.start.column,
f->location.end.line, f->location.end.column,
quotearg_n_style (2, c_quoting_style, f->fix));
}
void
fixits_register (location const *loc, char const* fix)
{
if (!fixits)
fixits = gl_list_create_empty (GL_ARRAY_LIST,
/* equals */ NULL,
/* hashcode */ NULL,
(gl_listelement_dispose_fn) fixit_free,
true);
fixit *f = fixit_new (loc, fix);
gl_list_add_last (fixits, f);
if (feature_flag & feature_fixit_parsable)
fixit_print (f, stderr);
}
bool
fixits_empty (void)
{
return !fixits;
}
void
fixits_run (void)
{
if (!fixits)
return;
/* This is not unlike what is done in location_caret. */
uniqstr input = ((fixit *) gl_list_get_at (fixits, 0))->location.start.file;
/* Backup the file. */
char buf[256];
size_t len = sizeof (buf);
char *backup = asnprintf (buf, &len, "%s~", input);
if (!backup)
xalloc_die ();
if (rename (input, backup))
error (EXIT_FAILURE, get_errno (),
_("%s: cannot backup"), quotearg_colon (input));
FILE *in = xfopen (backup, "r");
FILE *out = xfopen (input, "w");
size_t line = 1;
size_t offset = 1;
fixit const *f = NULL;
gl_list_iterator_t iter = gl_list_iterator (fixits);
while (gl_list_iterator_next (&iter, (const void**) &f, NULL))
{
/* Look for the correct line. */
while (line < f->location.start.line)
{
int c = getc (in);
if (c == EOF)
break;
if (c == '\n')
{
++line;
offset = 1;
}
putc (c, out);
}
/* Look for the right offset. */
while (offset < f->location.start.column)
{
int c = getc (in);
if (c == EOF)
break;
++offset;
putc (c, out);
}
/* Paste the fix instead. */
fputs (f->fix, out);
/* Skip the bad input. */
while (line < f->location.end.line)
{
int c = getc (in);
if (c == EOF)
break;
if (c == '\n')
{
++line;
offset = 1;
}
}
while (offset < f->location.end.column)
{
int c = getc (in);
if (c == EOF)
break;
++offset;
}
/* If erasing the content of a full line, also remove the
end-of-line. */
if (f->fix[0] == 0 && f->location.start.column == 1)
{
int c = getc (in);
if (c == EOF)
break;
else if (c == '\n')
{
++line;
offset = 1;
}
else
ungetc (c, in);
}
}
/* Paste the rest of the file. */
{
int c;
while ((c = getc (in)) != EOF)
putc (c, out);
}
gl_list_iterator_free (&iter);
xfclose (out);
xfclose (in);
fprintf (stderr, "%s: file %s was updated (backup: %s)\n",
program_name, quote_n (0, input), quote_n (1, backup));
if (backup != buf)
free (backup);
}
/* Free the registered fixits. */
void fixits_free (void)
{
if (fixits)
{
gl_list_free (fixits);
fixits = NULL;
}
}
+35
View File
@@ -0,0 +1,35 @@
/* Support for fixing grammar files.
Copyright (C) 2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef FIXITS_H_
# define FIXITS_H_ 1
# include "location.h"
/* Declare a fix to apply. */
void fixits_register (location const *loc, char const* update);
/* Apply the fixits: update the source file. */
void fixits_run (void);
/* Whether there are no fixits. */
bool fixits_empty (void);
/* Free the registered fixits. */
void fixits_free (void);
#endif /* !FIXITS_H_ */
+19 -7
View File
@@ -36,12 +36,13 @@
#include "quote.h" #include "quote.h"
#include "uniqstr.h" #include "uniqstr.h"
bool defines_flag; bool defines_flag = false;
bool graph_flag; bool graph_flag = false;
bool xml_flag; bool xml_flag = false;
bool no_lines_flag; bool no_lines_flag = false;
bool token_table_flag; bool token_table_flag = false;
bool yacc_flag; /* for -y */ location yacc_loc = EMPTY_LOCATION_INIT;
bool update_flag = false; /* for -u */
bool nondeterministic_parser = false; bool nondeterministic_parser = false;
bool glr_parser = false; bool glr_parser = false;
@@ -228,6 +229,7 @@ static const char * const feature_args[] =
{ {
"none", "none",
"caret", "diagnostics-show-caret", "caret", "diagnostics-show-caret",
"fixit", "diagnostics-parseable-fixits",
"all", "all",
0 0
}; };
@@ -236,6 +238,7 @@ static const int feature_types[] =
{ {
feature_none, feature_none,
feature_caret, feature_caret, feature_caret, feature_caret,
feature_fixit_parsable, feature_fixit_parsable,
feature_all feature_all
}; };
@@ -281,7 +284,10 @@ Operation modes:\n\
-h, --help display this help and exit\n\ -h, --help display this help and exit\n\
-V, --version output version information and exit\n\ -V, --version output version information and exit\n\
--print-localedir output directory containing locale-dependent data\n\ --print-localedir output directory containing locale-dependent data\n\
and exit\n\
--print-datadir output directory containing skeletons and XSLT\n\ --print-datadir output directory containing skeletons and XSLT\n\
and exit\n\
-u, --update apply fixes to the source grammar file\n\
-y, --yacc emulate POSIX Yacc\n\ -y, --yacc emulate POSIX Yacc\n\
-W, --warnings[=CATEGORY] report the warnings falling in CATEGORY\n\ -W, --warnings[=CATEGORY] report the warnings falling in CATEGORY\n\
-f, --feature[=FEATURE] activate miscellaneous features\n\ -f, --feature[=FEATURE] activate miscellaneous features\n\
@@ -476,6 +482,7 @@ static char const short_options[] =
"p:" "p:"
"r:" "r:"
"t" "t"
"u" /* --update */
"v" "v"
"x::" "x::"
"y" "y"
@@ -497,6 +504,7 @@ static struct option const long_options[] =
{ "version", no_argument, 0, 'V' }, { "version", no_argument, 0, 'V' },
{ "print-localedir", no_argument, 0, PRINT_LOCALEDIR_OPTION }, { "print-localedir", no_argument, 0, PRINT_LOCALEDIR_OPTION },
{ "print-datadir", no_argument, 0, PRINT_DATADIR_OPTION }, { "print-datadir", no_argument, 0, PRINT_DATADIR_OPTION },
{ "update", no_argument, 0, 'u' },
{ "warnings", optional_argument, 0, 'W' }, { "warnings", optional_argument, 0, 'W' },
/* Parser. */ /* Parser. */
@@ -682,6 +690,10 @@ getargs (int argc, char *argv[])
MUSCLE_PERCENT_DEFINE_D); MUSCLE_PERCENT_DEFINE_D);
break; break;
case 'u':
update_flag = true;
break;
case 'v': case 'v':
report_flag |= report_states; report_flag |= report_states;
break; break;
@@ -697,7 +709,7 @@ getargs (int argc, char *argv[])
case 'y': case 'y':
warning_argmatch ("error=yacc", 0, 6); warning_argmatch ("error=yacc", 0, 6);
yacc_flag = true; yacc_loc = command_line_location ();
break; break;
case LOCATIONS_OPTION: case LOCATIONS_OPTION:
+6 -5
View File
@@ -39,8 +39,8 @@ extern bool graph_flag; /* for -g */
extern bool xml_flag; /* for -x */ extern bool xml_flag; /* for -x */
extern bool no_lines_flag; /* for -l */ extern bool no_lines_flag; /* for -l */
extern bool token_table_flag; /* for -k */ extern bool token_table_flag; /* for -k */
extern bool yacc_flag; /* for -y */ extern location yacc_loc; /* for -y */
extern bool update_flag; /* for -u */
/* GLR_PARSER is true if the input file says to use the GLR /* GLR_PARSER is true if the input file says to use the GLR
(Generalized LR) parser, and to output some additional information (Generalized LR) parser, and to output some additional information
@@ -114,9 +114,10 @@ extern int trace_flag;
enum feature enum feature
{ {
feature_none = 0, /**< No additional feature. */ feature_none = 0, /**< No additional feature. */
feature_caret = 1 << 0, /**< Enhance the output of errors with carets. */ feature_caret = 1 << 0, /**< Output errors with carets. */
feature_all = ~0 /**< All above features. */ feature_fixit_parsable = 1 << 1, /**< Issue instructions to fix the sources. */
feature_all = ~0 /**< All above features. */
}; };
/** What additional features to use. */ /** What additional features to use. */
extern int feature_flag; extern int feature_flag;
+2
View File
@@ -46,6 +46,8 @@ src_bison_SOURCES = \
src/derives.h \ src/derives.h \
src/files.c \ src/files.c \
src/files.h \ src/files.h \
src/fixits.c \
src/fixits.h \
src/flex-scanner.h \ src/flex-scanner.h \
src/getargs.c \ src/getargs.c \
src/getargs.h \ src/getargs.h \
+8 -1
View File
@@ -209,13 +209,20 @@ location_caret (location loc, FILE *out)
/* Print the carets (at least one), with the same indent as above.*/ /* Print the carets (at least one), with the same indent as above.*/
fprintf (out, " %*s", loc.start.column - 1, ""); fprintf (out, " %*s", loc.start.column - 1, "");
for (i = loc.start.column; i == loc.start.column || i < len; ++i) for (i = loc.start.column; i == loc.start.column || i < len; ++i)
putc ('^', out); putc (i == loc.start.column ? '^' : '~', out);
} }
putc ('\n', out); putc ('\n', out);
} }
} }
} }
bool
location_empty (location loc)
{
return !loc.start.file && !loc.start.line && !loc.start.column
&& !loc.end.file && !loc.end.line && !loc.end.column;
}
void void
boundary_set_from_string (boundary *bound, char *loc_str) boundary_set_from_string (boundary *bound, char *loc_str)
{ {
+3
View File
@@ -126,6 +126,9 @@ location_cmp (location a, location b)
return res; return res;
} }
/* Whether this is the empty location. */
bool location_empty (location loc);
/* LOC_STR must be formatted as 'file:line.column', it will be modified. */ /* LOC_STR must be formatted as 'file:line.column', it will be modified. */
void boundary_set_from_string (boundary *bound, char *loc_str); void boundary_set_from_string (boundary *bound, char *loc_str);
+14 -1
View File
@@ -35,6 +35,7 @@
#include "conflicts.h" #include "conflicts.h"
#include "derives.h" #include "derives.h"
#include "files.h" #include "files.h"
#include "fixits.h"
#include "getargs.h" #include "getargs.h"
#include "gram.h" #include "gram.h"
#include "lalr.h" #include "lalr.h"
@@ -210,7 +211,6 @@ main (int argc, char *argv[])
contains things such as user actions, prologue, epilogue etc. */ contains things such as user actions, prologue, epilogue etc. */
gram_scanner_free (); gram_scanner_free ();
muscle_free (); muscle_free ();
uniqstrs_free ();
code_scanner_free (); code_scanner_free ();
skel_scanner_free (); skel_scanner_free ();
quotearg_free (); quotearg_free ();
@@ -227,5 +227,18 @@ main (int argc, char *argv[])
cleanup_caret (); cleanup_caret ();
/* Fix input file now, even if there are errors: that's less
warnings in the following runs. */
if (!fixits_empty ())
{
if (update_flag)
fixits_run ();
else
complain (NULL, Wother,
_("fix-its can be applied. Rerun with option '--update'."));
fixits_free ();
}
uniqstrs_free ();
return complaint_status ? EXIT_FAILURE : EXIT_SUCCESS; return complaint_status ? EXIT_FAILURE : EXIT_SUCCESS;
} }
+48 -28
View File
@@ -24,6 +24,7 @@
#include "complain.h" #include "complain.h"
#include "files.h" #include "files.h"
#include "fixits.h"
#include "getargs.h" #include "getargs.h"
#include "muscle-tab.h" #include "muscle-tab.h"
#include "quote.h" #include "quote.h"
@@ -429,12 +430,14 @@ define_directive (char const *assignment,
/** If the \a variable name is obsolete, return the name to use, /** If the \a variable name is obsolete, return the name to use,
* otherwise \a variable. If the \a value is obsolete, update it too. * otherwise \a variable. If the \a value is obsolete, update it too.
* *
* Allocates the returned value. */ * Allocates the returned value if needed, otherwise the returned
* value is exactly \a variable. */
static static
char * char const *
muscle_percent_variable_update (char const *variable, location variable_loc, muscle_percent_variable_update (char const *variable,
muscle_kind kind, muscle_kind kind,
char const **value) char const **value,
char **old, char **upd)
{ {
typedef struct typedef struct
{ {
@@ -444,8 +447,15 @@ muscle_percent_variable_update (char const *variable, location variable_loc,
} conversion_type; } conversion_type;
const conversion_type conversion[] = const conversion_type conversion[] =
{ {
{ "%error-verbose", "parse.error=verbose", muscle_keyword },
{ "%error_verbose", "parse.error=verbose", muscle_keyword },
{ "abstract", "api.parser.abstract", muscle_keyword },
{ "annotations", "api.parser.annotations", muscle_code },
{ "api.push_pull", "api.push-pull", muscle_keyword }, { "api.push_pull", "api.push-pull", muscle_keyword },
{ "api.tokens.prefix", "api.token.prefix", muscle_code }, { "api.tokens.prefix", "api.token.prefix", muscle_code },
{ "extends", "api.parser.extends", muscle_keyword },
{ "final", "api.parser.final", muscle_keyword },
{ "implements", "api.parser.implements", muscle_keyword },
{ "lex_symbol", "api.token.constructor", -1 }, { "lex_symbol", "api.token.constructor", -1 },
{ "location_type", "api.location.type", muscle_code }, { "location_type", "api.location.type", muscle_code },
{ "lr.default-reductions", "lr.default-reduction", muscle_keyword }, { "lr.default-reductions", "lr.default-reduction", muscle_keyword },
@@ -453,16 +463,11 @@ muscle_percent_variable_update (char const *variable, location variable_loc,
{ "lr.keep_unreachable_states", "lr.keep-unreachable-state", muscle_keyword }, { "lr.keep_unreachable_states", "lr.keep-unreachable-state", muscle_keyword },
{ "namespace", "api.namespace", muscle_code }, { "namespace", "api.namespace", muscle_code },
{ "parser_class_name", "api.parser.class", muscle_code }, { "parser_class_name", "api.parser.class", muscle_code },
{ "public", "api.parser.public", muscle_keyword },
{ "strictfp", "api.parser.strictfp", muscle_keyword },
{ "stype", "api.value.type", -1 }, { "stype", "api.value.type", -1 },
{ "variant=", "api.value.type=variant", -1 }, { "variant=", "api.value.type=variant", -1 },
{ "variant=true", "api.value.type=variant", -1 }, { "variant=true", "api.value.type=variant", -1 },
{ "abstract", "api.parser.abstract", muscle_keyword },
{ "annotations", "api.parser.annotations", muscle_code },
{ "extends", "api.parser.extends", muscle_keyword },
{ "final", "api.parser.final", muscle_keyword },
{ "implements", "api.parser.implements", muscle_keyword },
{ "public", "api.parser.public", muscle_keyword },
{ "strictfp", "api.parser.strictfp", muscle_keyword },
{ NULL, NULL, -1, } { NULL, NULL, -1, }
}; };
@@ -474,22 +479,25 @@ muscle_percent_variable_update (char const *variable, location variable_loc,
&& STREQ (eq + 1, *value)) && STREQ (eq + 1, *value))
: STREQ (c->obsolete, variable)) : STREQ (c->obsolete, variable))
{ {
char *old = define_directive (c->obsolete, kind, *value); /* Generate the deprecation warning. */
char *upd = define_directive (c->updated, c->kind, *value); *old = c->obsolete[0] == '%'
deprecated_directive (&variable_loc, old, upd); ? xstrdup (c->obsolete)
free (old); : define_directive (c->obsolete, kind, *value);
free (upd); *upd = define_directive (c->updated, c->kind, *value);
char *res = xstrdup (c->updated); /* Update the variable and its value. */
char *eq2 = strchr (res, '='); {
if (eq2) char *res = xstrdup (c->updated);
{ char *eq2 = strchr (res, '=');
*eq2 = '\0'; if (eq2)
*value = eq2 + 1; {
} *eq2 = '\0';
return res; *value = eq2 + 1;
}
return res;
}
} }
} }
return xstrdup (variable); return variable;
} }
void void
@@ -499,8 +507,11 @@ muscle_percent_define_insert (char const *var, location variable_loc,
muscle_percent_define_how how) muscle_percent_define_how how)
{ {
/* Backward compatibility. */ /* Backward compatibility. */
char *variable char *old = NULL;
= muscle_percent_variable_update (var, variable_loc, kind, &value); char *upd = NULL;
char const *variable
= muscle_percent_variable_update (var, kind,
&value, &old, &upd);
uniqstr name = muscle_name (variable, NULL); uniqstr name = muscle_name (variable, NULL);
uniqstr loc_name = muscle_name (variable, "loc"); uniqstr loc_name = muscle_name (variable, "loc");
uniqstr syncline_name = muscle_name (variable, "syncline"); uniqstr syncline_name = muscle_name (variable, "syncline");
@@ -508,6 +519,7 @@ muscle_percent_define_insert (char const *var, location variable_loc,
uniqstr kind_name = muscle_name (variable, "kind"); uniqstr kind_name = muscle_name (variable, "kind");
/* Command-line options are processed before the grammar file. */ /* Command-line options are processed before the grammar file. */
bool warned = false;
if (how == MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE if (how == MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE
&& muscle_find_const (name)) && muscle_find_const (name))
{ {
@@ -521,8 +533,13 @@ muscle_percent_define_insert (char const *var, location variable_loc,
i += SUB_INDENT; i += SUB_INDENT;
location loc = muscle_percent_define_get_loc (variable); location loc = muscle_percent_define_get_loc (variable);
complain_indent (&loc, complaint, &i, _("previous definition")); complain_indent (&loc, complaint, &i, _("previous definition"));
fixits_register (&variable_loc, "");
warned = true;
} }
if (!warned && old && upd)
deprecated_directive (&variable_loc, old, upd);
MUSCLE_INSERT_STRING (name, value); MUSCLE_INSERT_STRING (name, value);
muscle_insert (loc_name, ""); muscle_insert (loc_name, "");
muscle_location_grow (loc_name, variable_loc); muscle_location_grow (loc_name, variable_loc);
@@ -533,7 +550,10 @@ muscle_percent_define_insert (char const *var, location variable_loc,
MUSCLE_INSERT_INT (how_name, how); MUSCLE_INSERT_INT (how_name, how);
MUSCLE_INSERT_STRING (kind_name, muscle_kind_string (kind)); MUSCLE_INSERT_STRING (kind_name, muscle_kind_string (kind));
end: end:
free (variable); free (old);
free (upd);
if (variable != var)
free ((char *) variable);
} }
/* This is used for backward compatibility, e.g., "%define api.pure" /* This is used for backward compatibility, e.g., "%define api.pure"
+1 -1
View File
@@ -665,7 +665,7 @@ prepare (void)
MUSCLE_INSERT_BOOL ("tag_seen_flag", tag_seen); MUSCLE_INSERT_BOOL ("tag_seen_flag", tag_seen);
MUSCLE_INSERT_BOOL ("token_table_flag", token_table_flag); MUSCLE_INSERT_BOOL ("token_table_flag", token_table_flag);
MUSCLE_INSERT_BOOL ("use_push_for_pull_flag", use_push_for_pull_flag); MUSCLE_INSERT_BOOL ("use_push_for_pull_flag", use_push_for_pull_flag);
MUSCLE_INSERT_BOOL ("yacc_flag", yacc_flag); MUSCLE_INSERT_BOOL ("yacc_flag", !location_empty (yacc_loc));
/* File names. */ /* File names. */
if (spec_name_prefix) if (spec_name_prefix)
+861 -716
View File
File diff suppressed because it is too large Load Diff
+61 -51
View File
@@ -1,8 +1,9 @@
/* A Bison parser, made by GNU Bison 3.2.1.108-19b4e. */ /* A Bison parser, made by GNU Bison 3.2.90.23-0bbcb-dirty. */
/* Bison interface for Yacc-like parsers in C /* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc. Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -51,11 +52,11 @@
extern int gram_debug; extern int gram_debug;
#endif #endif
/* "%code requires" blocks. */ /* "%code requires" blocks. */
#line 21 "src/parse-gram.y" /* yacc.c:1917 */ #line 21 "src/parse-gram.y" /* yacc.c:1921 */
#include "symlist.h" #include "symlist.h"
#include "symtab.h" #include "symtab.h"
#line 218 "src/parse-gram.y" /* yacc.c:1917 */ #line 239 "src/parse-gram.y" /* yacc.c:1921 */
typedef enum typedef enum
{ {
@@ -64,7 +65,7 @@ extern int gram_debug;
param_parse = 1 << 1, param_parse = 1 << 1,
param_both = param_lex | param_parse param_both = param_lex | param_parse
} param_type; } param_type;
#line 660 "src/parse-gram.y" /* yacc.c:1917 */ #line 682 "src/parse-gram.y" /* yacc.c:1921 */
#include "muscle-tab.h" #include "muscle-tab.h"
typedef struct typedef struct
@@ -73,7 +74,7 @@ extern int gram_debug;
muscle_kind kind; muscle_kind kind;
} value_type; } value_type;
#line 77 "src/parse-gram.h" /* yacc.c:1917 */ #line 78 "src/parse-gram.h" /* yacc.c:1921 */
/* Token type. */ /* Token type. */
#ifndef GRAM_TOKENTYPE #ifndef GRAM_TOKENTYPE
@@ -98,43 +99,44 @@ extern int gram_debug;
PERCENT_DEFAULT_PREC = 272, PERCENT_DEFAULT_PREC = 272,
PERCENT_DEFINE = 273, PERCENT_DEFINE = 273,
PERCENT_DEFINES = 274, PERCENT_DEFINES = 274,
PERCENT_EXPECT = 275, PERCENT_ERROR_VERBOSE = 275,
PERCENT_EXPECT_RR = 276, PERCENT_EXPECT = 276,
PERCENT_FLAG = 277, PERCENT_EXPECT_RR = 277,
PERCENT_FILE_PREFIX = 278, PERCENT_FLAG = 278,
PERCENT_GLR_PARSER = 279, PERCENT_FILE_PREFIX = 279,
PERCENT_INITIAL_ACTION = 280, PERCENT_GLR_PARSER = 280,
PERCENT_LANGUAGE = 281, PERCENT_INITIAL_ACTION = 281,
PERCENT_NAME_PREFIX = 282, PERCENT_LANGUAGE = 282,
PERCENT_NO_DEFAULT_PREC = 283, PERCENT_NAME_PREFIX = 283,
PERCENT_NO_LINES = 284, PERCENT_NO_DEFAULT_PREC = 284,
PERCENT_NONDETERMINISTIC_PARSER = 285, PERCENT_NO_LINES = 285,
PERCENT_OUTPUT = 286, PERCENT_NONDETERMINISTIC_PARSER = 286,
PERCENT_REQUIRE = 287, PERCENT_OUTPUT = 287,
PERCENT_SKELETON = 288, PERCENT_REQUIRE = 288,
PERCENT_START = 289, PERCENT_SKELETON = 289,
PERCENT_TOKEN_TABLE = 290, PERCENT_START = 290,
PERCENT_VERBOSE = 291, PERCENT_TOKEN_TABLE = 291,
PERCENT_YACC = 292, PERCENT_VERBOSE = 292,
BRACED_CODE = 293, PERCENT_YACC = 293,
BRACED_PREDICATE = 294, BRACED_CODE = 294,
BRACKETED_ID = 295, BRACED_PREDICATE = 295,
CHAR = 296, BRACKETED_ID = 296,
EPILOGUE = 297, CHAR = 297,
EQUAL = 298, EPILOGUE = 298,
ID = 299, EQUAL = 299,
ID_COLON = 300, ID = 300,
PERCENT_PERCENT = 301, ID_COLON = 301,
PIPE = 302, PERCENT_PERCENT = 302,
PROLOGUE = 303, PIPE = 303,
SEMICOLON = 304, PROLOGUE = 304,
TAG = 305, SEMICOLON = 305,
TAG_ANY = 306, TAG = 306,
TAG_NONE = 307, TAG_ANY = 307,
INT = 308, TAG_NONE = 308,
PERCENT_PARAM = 309, INT = 309,
PERCENT_UNION = 310, PERCENT_PARAM = 310,
PERCENT_EMPTY = 311 PERCENT_UNION = 311,
PERCENT_EMPTY = 312
}; };
#endif #endif
@@ -161,9 +163,9 @@ union GRAM_STYPE
/* "integer" */ /* "integer" */
int INT; int INT;
/* int.opt */ /* int.opt */
int yytype_78; int yytype_79;
/* named_ref.opt */ /* named_ref.opt */
named_ref* yytype_90; named_ref* yytype_91;
/* "%param" */ /* "%param" */
param_type PERCENT_PARAM; param_type PERCENT_PARAM;
/* token_decl */ /* token_decl */
@@ -179,7 +181,7 @@ union GRAM_STYPE
/* string_as_id */ /* string_as_id */
symbol* string_as_id; symbol* string_as_id;
/* string_as_id.opt */ /* string_as_id.opt */
symbol* yytype_97; symbol* yytype_98;
/* generic_symlist */ /* generic_symlist */
symbol_list* generic_symlist; symbol_list* generic_symlist;
/* generic_symlist_item */ /* generic_symlist_item */
@@ -189,17 +191,25 @@ union GRAM_STYPE
/* token_decls */ /* token_decls */
symbol_list* token_decls; symbol_list* token_decls;
/* token_decl.1 */ /* token_decl.1 */
symbol_list* yytype_76; symbol_list* yytype_77;
/* token_decls_for_prec */ /* token_decls_for_prec */
symbol_list* token_decls_for_prec; symbol_list* token_decls_for_prec;
/* token_decl_for_prec.1 */ /* token_decl_for_prec.1 */
symbol_list* yytype_80; symbol_list* yytype_81;
/* symbol_decls */ /* symbol_decls */
symbol_list* symbol_decls; symbol_list* symbol_decls;
/* symbol_decl.1 */ /* symbol_decl.1 */
symbol_list* yytype_83; symbol_list* yytype_84;
/* "%error-verbose" */
uniqstr PERCENT_ERROR_VERBOSE;
/* "%<flag>" */ /* "%<flag>" */
uniqstr PERCENT_FLAG; uniqstr PERCENT_FLAG;
/* "%file-prefix" */
uniqstr PERCENT_FILE_PREFIX;
/* "%name-prefix" */
uniqstr PERCENT_NAME_PREFIX;
/* "%yacc" */
uniqstr PERCENT_YACC;
/* "[identifier]" */ /* "[identifier]" */
uniqstr BRACKETED_ID; uniqstr BRACKETED_ID;
/* "identifier" */ /* "identifier" */
@@ -209,7 +219,7 @@ union GRAM_STYPE
/* "<tag>" */ /* "<tag>" */
uniqstr TAG; uniqstr TAG;
/* tag.opt */ /* tag.opt */
uniqstr yytype_70; uniqstr yytype_71;
/* tag */ /* tag */
uniqstr tag; uniqstr tag;
/* variable */ /* variable */
@@ -218,7 +228,7 @@ union GRAM_STYPE
unsigned char CHAR; unsigned char CHAR;
/* value */ /* value */
value_type value; value_type value;
#line 222 "src/parse-gram.h" /* yacc.c:1917 */ #line 232 "src/parse-gram.h" /* yacc.c:1921 */
}; };
typedef union GRAM_STYPE GRAM_STYPE; typedef union GRAM_STYPE GRAM_STYPE;
+120 -12
View File
@@ -43,8 +43,9 @@
#include "named-ref.h" #include "named-ref.h"
#include "quotearg.h" #include "quotearg.h"
#include "reader.h" #include "reader.h"
#include "scan-gram.h"
#include "scan-code.h" #include "scan-code.h"
#include "scan-gram.h"
#include "vasnprintf.h"
#include "xmemdup0.h" #include "xmemdup0.h"
static int current_prec = 0; static int current_prec = 0;
@@ -81,11 +82,26 @@
string from the scanner (should be CODE). */ string from the scanner (should be CODE). */
static char const *translate_code_braceless (char *code, location loc); static char const *translate_code_braceless (char *code, location loc);
/* Handle a %error-verbose directive. */
static void handle_error_verbose (location const *loc, char const *directive);
/* Handle a %file-prefix directive. */
static void handle_file_prefix (location const *loc,
location const *dir_loc,
char const *directive, char const *value);
/* Handle a %name-prefix directive. */
static void handle_name_prefix (location const *loc,
char const *directive, char const *value);
/* Handle a %require directive. */ /* Handle a %require directive. */
static void do_require (location const *loc, char const *version); static void handle_require (location const *loc, char const *version);
/* Handle a %skeleton directive. */ /* Handle a %skeleton directive. */
static void do_skeleton (location const *loc, char const *skel); static void handle_skeleton (location const *loc, char const *skel);
/* Handle a %yacc directive. */
static void handle_yacc (location const *loc, char const *directive);
static void gram_error (location const *, char const *); static void gram_error (location const *, char const *);
@@ -146,6 +162,7 @@
PERCENT_DEFAULT_PREC "%default-prec" PERCENT_DEFAULT_PREC "%default-prec"
PERCENT_DEFINE "%define" PERCENT_DEFINE "%define"
PERCENT_DEFINES "%defines" PERCENT_DEFINES "%defines"
PERCENT_ERROR_VERBOSE "%error-verbose"
PERCENT_EXPECT "%expect" PERCENT_EXPECT "%expect"
PERCENT_EXPECT_RR "%expect-rr" PERCENT_EXPECT_RR "%expect-rr"
PERCENT_FLAG "%<flag>" PERCENT_FLAG "%<flag>"
@@ -190,7 +207,11 @@
%printer { fputs (quotearg_style (c_quoting_style, $$), yyo); } STRING %printer { fputs (quotearg_style (c_quoting_style, $$), yyo); } STRING
%printer { fprintf (yyo, "{\n%s\n}", $$); } <char*> %printer { fprintf (yyo, "{\n%s\n}", $$); } <char*>
%type <uniqstr> BRACKETED_ID ID ID_COLON PERCENT_FLAG TAG tag tag.opt variable %type <uniqstr>
BRACKETED_ID ID ID_COLON
PERCENT_ERROR_VERBOSE PERCENT_FILE_PREFIX PERCENT_FLAG PERCENT_NAME_PREFIX
PERCENT_YACC
TAG tag tag.opt variable
%printer { fputs ($$, yyo); } <uniqstr> %printer { fputs ($$, yyo); } <uniqstr>
%printer { fprintf (yyo, "[%s]", $$); } BRACKETED_ID %printer { fprintf (yyo, "[%s]", $$); } BRACKETED_ID
%printer { fprintf (yyo, "%s:", $$); } ID_COLON %printer { fprintf (yyo, "%s:", $$); } ID_COLON
@@ -284,7 +305,7 @@ prologue_declaration:
} }
| "%define" variable value | "%define" variable value
{ {
muscle_percent_define_insert ($2, @2, $3.kind, $3.chars, muscle_percent_define_insert ($2, @$, $3.kind, $3.chars,
MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE); MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
} }
| "%defines" { defines_flag = true; } | "%defines" { defines_flag = true; }
@@ -293,9 +314,10 @@ prologue_declaration:
defines_flag = true; defines_flag = true;
spec_defines_file = xstrdup ($2); spec_defines_file = xstrdup ($2);
} }
| "%error-verbose" { handle_error_verbose (&@$, $1); }
| "%expect" INT { expected_sr_conflicts = $2; } | "%expect" INT { expected_sr_conflicts = $2; }
| "%expect-rr" INT { expected_rr_conflicts = $2; } | "%expect-rr" INT { expected_rr_conflicts = $2; }
| "%file-prefix" STRING { spec_file_prefix = $2; } | "%file-prefix" STRING { handle_file_prefix (&@$, &@1, $1, $2); }
| "%glr-parser" | "%glr-parser"
{ {
nondeterministic_parser = true; nondeterministic_parser = true;
@@ -307,16 +329,16 @@ prologue_declaration:
code_scanner_last_string_free (); code_scanner_last_string_free ();
} }
| "%language" STRING { language_argmatch ($2, grammar_prio, @1); } | "%language" STRING { language_argmatch ($2, grammar_prio, @1); }
| "%name-prefix" STRING { spec_name_prefix = $2; } | "%name-prefix" STRING { handle_name_prefix (&@$, $1, $2); }
| "%no-lines" { no_lines_flag = true; } | "%no-lines" { no_lines_flag = true; }
| "%nondeterministic-parser" { nondeterministic_parser = true; } | "%nondeterministic-parser" { nondeterministic_parser = true; }
| "%output" STRING { spec_outfile = $2; } | "%output" STRING { spec_outfile = $2; }
| "%param" { current_param = $1; } params { current_param = param_none; } | "%param" { current_param = $1; } params { current_param = param_none; }
| "%require" STRING { do_require (&@2, $2); } | "%require" STRING { handle_require (&@2, $2); }
| "%skeleton" STRING { do_skeleton (&@2, $2); } | "%skeleton" STRING { handle_skeleton (&@2, $2); }
| "%token-table" { token_table_flag = true; } | "%token-table" { token_table_flag = true; }
| "%verbose" { report_flag |= report_states; } | "%verbose" { report_flag |= report_states; }
| "%yacc" { yacc_flag = true; } | "%yacc" { handle_yacc (&@$, $1); }
| error ";" { current_class = unknown_sym; yyerrok; } | error ";" { current_class = unknown_sym; yyerrok; }
| /*FIXME: Err? What is this horror doing here? */ ";" | /*FIXME: Err? What is this horror doing here? */ ";"
; ;
@@ -847,7 +869,74 @@ add_param (param_type type, char *decl, location loc)
static void static void
do_require (location const *loc, char const *version) handle_error_verbose (location const *loc, char const *directive)
{
bison_directive (loc, directive);
muscle_percent_define_insert (directive, *loc, muscle_keyword, "",
MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
}
static void
handle_file_prefix (location const *loc,
location const *dir_loc,
char const *directive, char const *value)
{
bison_directive (loc, directive);
bool warned = false;
if (location_empty (spec_file_prefix_loc))
{
spec_file_prefix_loc = *loc;
spec_file_prefix = value;
}
else
{
duplicate_directive (directive, spec_file_prefix_loc, *loc);
warned = true;
}
if (!warned
&& STRNEQ (directive, "%file-prefix"))
deprecated_directive (dir_loc, directive, "%file-prefix");
}
static void
handle_name_prefix (location const *loc,
char const *directive, char const *value)
{
bison_directive (loc, directive);
char buf1[1024];
size_t len1 = sizeof (buf1);
char *old = asnprintf (buf1, &len1, "%s\"%s\"", directive, value);
if (!old)
xalloc_die ();
if (location_empty (spec_name_prefix_loc))
{
spec_name_prefix = value;
spec_name_prefix_loc = *loc;
char buf2[1024];
size_t len2 = sizeof (buf2);
char *new = asnprintf (buf2, &len2, "%%define api.prefix {%s}", value);
if (!new)
xalloc_die ();
deprecated_directive (loc, old, new);
if (new != buf2)
free (new);
}
else
duplicate_directive (old, spec_file_prefix_loc, *loc);
if (old != buf1)
free (old);
}
static void
handle_require (location const *loc, char const *version)
{ {
/* Changes of behavior are only on minor version changes, so "3.0.5" /* Changes of behavior are only on minor version changes, so "3.0.5"
is the same as "3.0". */ is the same as "3.0". */
@@ -885,7 +974,7 @@ do_require (location const *loc, char const *version)
} }
static void static void
do_skeleton (location const *loc, char const *skel) handle_skeleton (location const *loc, char const *skel)
{ {
char const *skeleton_user = skel; char const *skeleton_user = skel;
if (strchr (skeleton_user, '/')) if (strchr (skeleton_user, '/'))
@@ -909,6 +998,25 @@ do_skeleton (location const *loc, char const *skel)
skeleton_arg (skeleton_user, grammar_prio, *loc); skeleton_arg (skeleton_user, grammar_prio, *loc);
} }
static void
handle_yacc (location const *loc, char const *directive)
{
bison_directive (loc, directive);
bool warned = false;
if (location_empty (yacc_loc))
yacc_loc = *loc;
else
{
duplicate_directive (directive, yacc_loc, *loc);
warned = true;
}
if (!warned
&& STRNEQ (directive, "%fixed-output-files")
&& STRNEQ (directive, "%yacc"))
deprecated_directive (loc, directive, "%fixed-output-files");
}
static void static void
gram_error (location const *loc, char const *msg) gram_error (location const *loc, char const *msg)
+8 -8
View File
@@ -467,8 +467,8 @@ grammar_current_rule_prec_set (symbol *precsym, location loc)
not defined separately as a token. */ not defined separately as a token. */
symbol_class_set (precsym, token_sym, loc, false); symbol_class_set (precsym, token_sym, loc, false);
if (current_rule->ruleprec) if (current_rule->ruleprec)
duplicate_directive ("%prec", duplicate_rule_directive ("%prec",
current_rule->ruleprec->location, loc); current_rule->ruleprec->location, loc);
else else
current_rule->ruleprec = precsym; current_rule->ruleprec = precsym;
} }
@@ -483,8 +483,8 @@ grammar_current_rule_empty_set (location loc)
if (warning_is_unset (Wempty_rule)) if (warning_is_unset (Wempty_rule))
warning_argmatch ("empty-rule", 0, 0); warning_argmatch ("empty-rule", 0, 0);
if (current_rule->percent_empty_loc.start.file) if (current_rule->percent_empty_loc.start.file)
duplicate_directive ("%empty", duplicate_rule_directive ("%empty",
current_rule->percent_empty_loc, loc); current_rule->percent_empty_loc, loc);
else else
current_rule->percent_empty_loc = loc; current_rule->percent_empty_loc = loc;
} }
@@ -501,8 +501,8 @@ grammar_current_rule_dprec_set (int dprec, location loc)
complain (&loc, complaint, _("%s must be followed by positive number"), complain (&loc, complaint, _("%s must be followed by positive number"),
"%dprec"); "%dprec");
else if (current_rule->dprec != 0) else if (current_rule->dprec != 0)
duplicate_directive ("%dprec", duplicate_rule_directive ("%dprec",
current_rule->dprec_location, loc); current_rule->dprec_location, loc);
else else
{ {
current_rule->dprec = dprec; current_rule->dprec = dprec;
@@ -520,8 +520,8 @@ grammar_current_rule_merge_set (uniqstr name, location loc)
complain (&loc, Wother, _("%s affects only GLR parsers"), complain (&loc, Wother, _("%s affects only GLR parsers"),
"%merge"); "%merge");
if (current_rule->merger != 0) if (current_rule->merger != 0)
duplicate_directive ("%merge", duplicate_rule_directive ("%merge",
current_rule->merger_declaration_location, loc); current_rule->merger_declaration_location, loc);
else else
{ {
current_rule->merger = get_merge_function (name); current_rule->merger = get_merge_function (name);
+13 -16
View File
@@ -76,18 +76,17 @@ static size_t no_cr_read (FILE *, char *, size_t);
#define DEPRECATED(Msg) \ #define DEPRECATED(Msg) \
do { \ do { \
size_t i; \
deprecated_directive (loc, yytext, Msg); \ deprecated_directive (loc, yytext, Msg); \
scanner_cursor.column -= mbsnwidth (Msg, strlen (Msg), 0); \ scanner_cursor.column -= mbsnwidth (Msg, strlen (Msg), 0); \
for (i = strlen (Msg); i != 0; --i) \ for (size_t i = strlen (Msg); i != 0; --i) \
unput (Msg[i - 1]); \ unput (Msg[i - 1]); \
} while (0) } while (0)
/* A string representing the most recently saved token. */ /* A string representing the most recently saved token. */
static char *last_string; static char *last_string = NULL;
/* Bracketed identifier. */ /* Bracketed identifier. */
static uniqstr bracketed_id_str = 0; static uniqstr bracketed_id_str = NULL;
static location bracketed_id_loc; static location bracketed_id_loc;
static boundary bracketed_id_start; static boundary bracketed_id_start;
static int bracketed_id_context_state = 0; static int bracketed_id_context_state = 0;
@@ -145,7 +144,8 @@ splice (\\[ \f\t\v]*\n)*
/* An equal sign, with optional leading whitespaces. This is used in some /* An equal sign, with optional leading whitespaces. This is used in some
deprecated constructs. */ deprecated constructs. */
eqopt ([[:space:]]*=)? sp [[:space:]]*
eqopt ({sp}=)?
%% %%
%{ %{
@@ -228,8 +228,8 @@ eqopt ([[:space:]]*=)?
"%empty" return BISON_DIRECTIVE (EMPTY); "%empty" return BISON_DIRECTIVE (EMPTY);
"%expect" return BISON_DIRECTIVE (EXPECT); "%expect" return BISON_DIRECTIVE (EXPECT);
"%expect-rr" return BISON_DIRECTIVE (EXPECT_RR); "%expect-rr" return BISON_DIRECTIVE (EXPECT_RR);
"%file-prefix" return BISON_DIRECTIVE (FILE_PREFIX); "%file-prefix" RETURN_VALUE (PERCENT_FILE_PREFIX, uniqstr_new (yytext));
"%fixed-output-files" return BISON_DIRECTIVE (YACC); "%fixed-output-files" RETURN_VALUE (PERCENT_YACC, uniqstr_new (yytext));
"%initial-action" return BISON_DIRECTIVE (INITIAL_ACTION); "%initial-action" return BISON_DIRECTIVE (INITIAL_ACTION);
"%glr-parser" return BISON_DIRECTIVE (GLR_PARSER); "%glr-parser" return BISON_DIRECTIVE (GLR_PARSER);
"%language" return BISON_DIRECTIVE (LANGUAGE); "%language" return BISON_DIRECTIVE (LANGUAGE);
@@ -259,25 +259,22 @@ eqopt ([[:space:]]*=)?
"%type" return PERCENT_TYPE; "%type" return PERCENT_TYPE;
"%union" return PERCENT_UNION; "%union" return PERCENT_UNION;
"%verbose" return BISON_DIRECTIVE (VERBOSE); "%verbose" return BISON_DIRECTIVE (VERBOSE);
"%yacc" return BISON_DIRECTIVE (YACC); "%yacc" RETURN_VALUE (PERCENT_YACC, uniqstr_new (yytext));
/* Deprecated since Bison 3.0 (2013-07-25), but the warning is /* Deprecated since Bison 3.0 (2013-07-25), but the warning is
issued only since Bison 3.3. */ issued only since Bison 3.3. */
"%error-verbose" DEPRECATED ("%define parse.error verbose"); "%error-verbose" RETURN_VALUE (PERCENT_ERROR_VERBOSE, uniqstr_new (yytext));
/* Deprecated since Bison 2.6 (2012-07-19), but the warning is /* Deprecated since Bison 2.6 (2012-07-19), but the warning is
issued only since Bison 3.3. */ issued only since Bison 3.3. */
"%name"[-_]"prefix"{eqopt} { "%name"[-_]"prefix"{eqopt}{sp} RETURN_VALUE (PERCENT_NAME_PREFIX, uniqstr_new (yytext));
deprecated_directive (loc, yytext, "%define api.prefix");
return BISON_DIRECTIVE (NAME_PREFIX);
}
/* Deprecated since Bison 2.7.90, 2012. */ /* Deprecated since Bison 2.7.90, 2012. */
"%default"[-_]"prec" DEPRECATED ("%default-prec"); "%default"[-_]"prec" DEPRECATED ("%default-prec");
"%error"[-_]"verbose" DEPRECATED ("%define parse.error verbose"); "%error"[-_]"verbose" RETURN_VALUE (PERCENT_ERROR_VERBOSE, uniqstr_new (yytext));
"%expect"[-_]"rr" DEPRECATED ("%expect-rr"); "%expect"[-_]"rr" DEPRECATED ("%expect-rr");
"%file-prefix"{eqopt} DEPRECATED ("%file-prefix"); "%file-prefix"{eqopt} RETURN_VALUE (PERCENT_FILE_PREFIX, uniqstr_new (yytext));
"%fixed"[-_]"output"[-_]"files" DEPRECATED ("%fixed-output-files"); "%fixed"[-_]"output"[-_]"files" RETURN_VALUE (PERCENT_YACC, uniqstr_new (yytext));
"%no"[-_]"default"[-_]"prec" DEPRECATED ("%no-default-prec"); "%no"[-_]"default"[-_]"prec" DEPRECATED ("%no-default-prec");
"%no"[-_]"lines" DEPRECATED ("%no-lines"); "%no"[-_]"lines" DEPRECATED ("%no-lines");
"%output"{eqopt} DEPRECATED ("%output"); "%output"{eqopt} DEPRECATED ("%output");
+40 -13
View File
@@ -130,7 +130,7 @@ b: {} {};
AT_BISON_CHECK([-fcaret -Wempty-rule 1.y], [0], [], AT_BISON_CHECK([-fcaret -Wempty-rule 1.y], [0], [],
[[1.y:11.17-18: warning: empty rule without %empty [-Wempty-rule] [[1.y:11.17-18: warning: empty rule without %empty [-Wempty-rule]
a: /* empty. */ {}; a: /* empty. */ {};
^^ ^~
]]) ]])
AT_DATA_GRAMMAR([[2.y]], AT_DATA_GRAMMAR([[2.y]],
@@ -144,10 +144,10 @@ c: /* empty. */ {};
AT_BISON_CHECK([-fcaret 2.y], [0], [], AT_BISON_CHECK([-fcaret 2.y], [0], [],
[[2.y:11.17-18: warning: empty rule without %empty [-Wempty-rule] [[2.y:11.17-18: warning: empty rule without %empty [-Wempty-rule]
a: /* empty. */ {}; a: /* empty. */ {};
^^ ^~
2.y:13.17-18: warning: empty rule without %empty [-Wempty-rule] 2.y:13.17-18: warning: empty rule without %empty [-Wempty-rule]
c: /* empty. */ {}; c: /* empty. */ {};
^^ ^~
]]) ]])
AT_BISON_CHECK([-fcaret -Wno-empty-rule 2.y], [0]) AT_BISON_CHECK([-fcaret -Wno-empty-rule 2.y], [0])
@@ -170,12 +170,39 @@ exp:
AT_BISON_CHECK([-fcaret one.y], [1], [], AT_BISON_CHECK([-fcaret one.y], [1], [],
[[one.y:11.13-18: error: only one %empty allowed per rule [[one.y:11.13-18: error: only one %empty allowed per rule
%empty {} %empty %empty {} %empty
^^^^^^ ^~~~~~
one.y:11.3-8: previous declaration one.y:11.3-8: previous declaration
%empty {} %empty %empty {} %empty
^^^^^^ ^~~~~~
one.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
]]) ]])
AT_BISON_CHECK([-fcaret -u one.y], [1], [],
[[one.y:11.13-18: error: only one %empty allowed per rule
%empty {} %empty
^~~~~~
one.y:11.3-8: previous declaration
%empty {} %empty
^~~~~~
bison: file 'one.y' was updated (backup: 'one.y~')
]])
AT_CHECK([cat one.y], [],
[[%code top {
/* Load config.h, and adjust to the compiler.
We used to do it here, but each time we add a new line,
we have to adjust all the line numbers in error messages.
It's simpler to use a constant include to a varying file. */
#include <testsuite.h>
}
%%
exp:
%empty {} @&t@
;
]])
AT_DATA_GRAMMAR([[two.y]], AT_DATA_GRAMMAR([[two.y]],
[[%% [[%%
exp: exp:
@@ -188,13 +215,13 @@ exp:
AT_BISON_CHECK([-fcaret two.y], [1], [], AT_BISON_CHECK([-fcaret two.y], [1], [],
[[two.y:11.7-12: error: %empty on non-empty rule [[two.y:11.7-12: error: %empty on non-empty rule
'a' %empty {} 'a' %empty {}
^^^^^^ ^~~~~~
two.y:12.3-8: error: %empty on non-empty rule two.y:12.3-8: error: %empty on non-empty rule
| %empty 'a' {} | %empty 'a' {}
^^^^^^ ^~~~~~
two.y:13.3-8: error: %empty on non-empty rule two.y:13.3-8: error: %empty on non-empty rule
| %empty {} {} | %empty {} {}
^^^^^^ ^~~~~~
]]) ]])
AT_CLEANUP AT_CLEANUP
@@ -1514,16 +1541,16 @@ input.y:32.3-23: warning: unused value: $3 [-Wother]
AT_BISON_CHECK([-fcaret -o input.c input.y], 0,, AT_BISON_CHECK([-fcaret -o input.c input.y], 0,,
[[input.y:24.57-59: warning: useless %destructor for type <*> [-Wother] [[input.y:24.57-59: warning: useless %destructor for type <*> [-Wother]
%printer { #error "<*> printer should not be used" } <*> %printer { #error "<*> printer should not be used" } <*>
^^^ ^~~
input.y:24.57-59: warning: useless %printer for type <*> [-Wother] input.y:24.57-59: warning: useless %printer for type <*> [-Wother]
%printer { #error "<*> printer should not be used" } <*> %printer { #error "<*> printer should not be used" } <*>
^^^ ^~~
input.y:33.3-23: warning: unset value: $$ [-Wother] input.y:33.3-23: warning: unset value: $$ [-Wother]
{ @$ = 4; } // Only used. { @$ = 4; } // Only used.
^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~
input.y:32.3-23: warning: unused value: $3 [-Wother] input.y:32.3-23: warning: unused value: $3 [-Wother]
{ USE ($$); @$ = 3; } // Only set. { USE ($$); @$ = 3; } // Only set.
^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~
]]) ]])
AT_COMPILE([input]) AT_COMPILE([input])
+6 -6
View File
@@ -249,13 +249,13 @@ exp:
AT_BISON_CHECK([[-fcaret input.yy]], [0], [], AT_BISON_CHECK([[-fcaret input.yy]], [0], [],
[[input.yy:16.33-34: warning: multiple occurrences of $2 with api.value.automove [-Wother] [[input.yy:16.33-34: warning: multiple occurrences of $2 with api.value.automove [-Wother]
| "twice" exp { $$ = $2 + $2; } | "twice" exp { $$ = $2 + $2; }
^^ ^~
input.yy:17.33-36: warning: multiple occurrences of $2 with api.value.automove [-Wother] input.yy:17.33-36: warning: multiple occurrences of $2 with api.value.automove [-Wother]
| "thrice" exp[val] { $$ = $2 + $val + $2; } | "thrice" exp[val] { $$ = $2 + $val + $2; }
^^^^ ^~~~
input.yy:17.40-41: warning: multiple occurrences of $2 with api.value.automove [-Wother] input.yy:17.40-41: warning: multiple occurrences of $2 with api.value.automove [-Wother]
| "thrice" exp[val] { $$ = $2 + $val + $2; } | "thrice" exp[val] { $$ = $2 + $val + $2; }
^^ ^~
]]) ]])
AT_BISON_OPTION_POPDEFS AT_BISON_OPTION_POPDEFS
@@ -420,8 +420,7 @@ namespace yy
{ {
static static
]AT_YYLEX_PROTOTYPE[ ]AT_YYLEX_PROTOTYPE[
{]AT_LOCATION_IF([ {
typedef parser::location_type location;])[
// The 5 is a syntax error whose recovery requires that we discard // The 5 is a syntax error whose recovery requires that we discard
// the lookahead. This tests a regression, see // the lookahead. This tests a regression, see
// <http://savannah.gnu.org/support/?108481>. // <http://savannah.gnu.org/support/?108481>.
@@ -1243,7 +1242,8 @@ yylex (yy::parser::semantic_type *lvalp)
default: default:
lvalp->]AT_VARIANT_IF([build<Object> (res)], lvalp->]AT_VARIANT_IF([build<Object> (res)],
[obj = new Object (res)])[; [obj = new Object (res)])[;
// Fall through. goto zero;
zero:
case 0: case 0:
return res; return res;
} }
+6 -6
View File
@@ -246,16 +246,16 @@ f: B
AT_BISON_CHECK([-Wprecedence -fcaret -o input.c input.y], 0, [], AT_BISON_CHECK([-Wprecedence -fcaret -o input.c input.y], 0, [],
[[input.y:7.1-9: warning: useless precedence and associativity for U [-Wprecedence] [[input.y:7.1-9: warning: useless precedence and associativity for U [-Wprecedence]
%nonassoc U %nonassoc U
^^^^^^^^^ ^~~~~~~~~
input.y:6.1-6: warning: useless precedence and associativity for V [-Wprecedence] input.y:6.1-6: warning: useless precedence and associativity for V [-Wprecedence]
%right V %right V
^^^^^^ ^~~~~~
input.y:5.1-5: warning: useless precedence and associativity for W [-Wprecedence] input.y:5.1-5: warning: useless precedence and associativity for W [-Wprecedence]
%left W %left W
^^^^^ ^~~~~
input.y:2.1-11: warning: useless precedence for Z [-Wprecedence] input.y:2.1-11: warning: useless precedence for Z [-Wprecedence]
%precedence Z %precedence Z
^^^^^^^^^^^ ^~~~~~~~~~~
]]) ]])
AT_CLEANUP AT_CLEANUP
@@ -1367,7 +1367,7 @@ b: %expect-rr 4
AT_BISON_CHECK([-fcaret -o input.c input.y], 1, [], AT_BISON_CHECK([-fcaret -o input.c input.y], 1, [],
[[input.y:12.4-15: error: reduce/reduce conflicts for rule 8: 3 found, 4 expected [[input.y:12.4-15: error: reduce/reduce conflicts for rule 8: 3 found, 4 expected
b: %expect-rr 4 b: %expect-rr 4
^^^^^^^^^^^^ ^~~~~~~~~~~~
]]) ]])
AT_CLEANUP AT_CLEANUP
@@ -1396,7 +1396,7 @@ b: %expect-rr 2
AT_BISON_CHECK([-fcaret -o input.c input.y], 1, [], AT_BISON_CHECK([-fcaret -o input.c input.y], 1, [],
[[input.y:12.4-15: error: reduce/reduce conflicts for rule 8: 3 found, 2 expected [[input.y:12.4-15: error: reduce/reduce conflicts for rule 8: 3 found, 2 expected
b: %expect-rr 2 b: %expect-rr 2
^^^^^^^^^^^^ ^~~~~~~~~~~~
]]) ]])
AT_CLEANUP AT_CLEANUP
+3 -2
View File
@@ -85,7 +85,8 @@ exp: %empty;
]]) ]])
AT_BISON_CHECK([--defines -o input.c input.y], [], [], AT_BISON_CHECK([--defines -o input.c input.y], [], [],
[[input.y:11.1-12: warning: deprecated directive: '%name-prefix', use '%define api.prefix' [-Wdeprecated] [[input.y:11.1-18: warning: deprecated directive: '%name-prefix "my_"', use '%define api.prefix {my_}' [-Wdeprecated]
input.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
]]) ]])
# YYLTYPE should be defined, and MY_LLOC declared. # YYLTYPE should be defined, and MY_LLOC declared.
@@ -125,7 +126,7 @@ AT_BISON_OPTION_PUSHDEFS([$1])
AT_DATA_GRAMMAR([input.y], AT_DATA_GRAMMAR([input.y],
[[$1 [[$1
%define parse.error verbose %define parse.error verbose
]AT_VARIANT_IF([], [%union {int integer;}])[ ]AT_VARIANT_IF([%token <int> 'x'], [%union {int integer;}])[
%code { %code {
]AT_PUSH_IF([[ ]AT_PUSH_IF([[
#if defined __GNUC__ && 7 == __GNUC__ #if defined __GNUC__ && 7 == __GNUC__
+285 -209
View File
@@ -146,16 +146,16 @@ exp: "number";
AT_BISON_CHECK([-fcaret -Wyacc input.y], [0], [], AT_BISON_CHECK([-fcaret -Wyacc input.y], [0], [],
[[input.y:1.1-6: warning: POSIX Yacc does not support %nterm [-Wyacc] [[input.y:1.1-6: warning: POSIX Yacc does not support %nterm [-Wyacc]
%nterm exp %nterm exp
^^^^^^ ^~~~~~
input.y:2.12-15: warning: POSIX Yacc does not support hexadecimal literals [-Wyacc] input.y:2.12-15: warning: POSIX Yacc does not support hexadecimal literals [-Wyacc]
%token NUM 0x40 "number" %token NUM 0x40 "number"
^^^^ ^~~~
input.y:2.17-24: warning: POSIX Yacc does not support string literals [-Wyacc] input.y:2.17-24: warning: POSIX Yacc does not support string literals [-Wyacc]
%token NUM 0x40 "number" %token NUM 0x40 "number"
^^^^^^^^ ^~~~~~~~
input.y:4.6-13: warning: POSIX Yacc does not support string literals [-Wyacc] input.y:4.6-13: warning: POSIX Yacc does not support string literals [-Wyacc]
exp: "number"; exp: "number";
^^^^^^^^ ^~~~~~~~
]]) ]])
AT_CLEANUP AT_CLEANUP
@@ -180,16 +180,16 @@ b: %empty { $$ = 42; };
AT_BISON_CHECK([-fcaret -Wyacc input.y], [0], [], AT_BISON_CHECK([-fcaret -Wyacc input.y], [0], [],
[[input.y:1.1-11: warning: POSIX Yacc does not support %destructor [-Wyacc] [[input.y:1.1-11: warning: POSIX Yacc does not support %destructor [-Wyacc]
%destructor {} <int> %destructor {} <int>
^^^^^^^^^^^ ^~~~~~~~~~~
input.y:2.1-8: warning: POSIX Yacc does not support %printer [-Wyacc] input.y:2.1-8: warning: POSIX Yacc does not support %printer [-Wyacc]
%printer {} <int> %printer {} <int>
^^^^^^^^ ^~~~~~~~
input.y:6.9-20: warning: POSIX Yacc does not support typed midrule actions [-Wyacc] input.y:6.9-20: warning: POSIX Yacc does not support typed midrule actions [-Wyacc]
a: <int>{ $$ = 42; } { $$ = $1; }; a: <int>{ $$ = 42; } { $$ = $1; };
^^^^^^^^^^^^ ^~~~~~~~~~~~
input.y:7.4-9: warning: POSIX Yacc does not support %empty [-Wyacc] input.y:7.4-9: warning: POSIX Yacc does not support %empty [-Wyacc]
b: %empty { $$ = 42; }; b: %empty { $$ = 42; };
^^^^^^ ^~~~~~
]]) ]])
AT_CLEANUP AT_CLEANUP
@@ -219,25 +219,25 @@ fact: "number";
AT_BISON_CHECK([-fcaret input.y], [1], [], AT_BISON_CHECK([-fcaret input.y], [1], [],
[[input.y:1.13-24: error: nonterminals cannot be given a string alias [[input.y:1.13-24: error: nonterminals cannot be given a string alias
%nterm expr "expression"; %nterm expr "expression";
^^^^^^^^^^^^ ^~~~~~~~~~~~
input.y:2.13-15: error: nonterminals cannot be given an explicit number input.y:2.13-15: error: nonterminals cannot be given an explicit number
%nterm term 123; %nterm term 123;
^^^ ^~~
input.y:3.13-15: error: nonterminals cannot be given an explicit number input.y:3.13-15: error: nonterminals cannot be given an explicit number
%nterm fact 124 "factor"; %nterm fact 124 "factor";
^^^ ^~~
input.y:3.17-24: error: nonterminals cannot be given a string alias input.y:3.17-24: error: nonterminals cannot be given a string alias
%nterm fact 124 "factor"; %nterm fact 124 "factor";
^^^^^^^^ ^~~~~~~~
input.y:4.8-10: error: character literals cannot be nonterminals input.y:4.8-10: error: character literals cannot be nonterminals
%nterm '+' '*'; %nterm '+' '*';
^^^ ^~~
input.y:5.8-15: error: syntax error, unexpected string, expecting char or identifier or <tag> input.y:5.8-15: error: syntax error, unexpected string, expecting char or identifier or <tag>
%nterm "number"; %nterm "number";
^^^^^^^^ ^~~~~~~~
input.y:6.8-13: error: syntax error, unexpected string, expecting char or identifier or <tag> input.y:6.8-13: error: syntax error, unexpected string, expecting char or identifier or <tag>
%token "tok1" 1; %token "tok1" 1;
^^^^^^ ^~~~~~
input.y:7.14: error: syntax error, unexpected integer input.y:7.14: error: syntax error, unexpected integer
%left "tok2" 2; %left "tok2" 2;
^ ^
@@ -364,10 +364,10 @@ exp: %empty { @$ = @1 ; };
AT_BISON_CHECK([-fcaret input.y], [1], [], AT_BISON_CHECK([-fcaret input.y], [1], [],
[[input.y:2.20-21: error: integer out of range: '$1' [[input.y:2.20-21: error: integer out of range: '$1'
exp: %empty { $$ = $1 ; }; exp: %empty { $$ = $1 ; };
^^ ^~
input.y:3.20-21: error: integer out of range: '@1' input.y:3.20-21: error: integer out of range: '@1'
exp: %empty { @$ = @1 ; }; exp: %empty { @$ = @1 ; };
^^ ^~
]]) ]])
AT_CLEANUP AT_CLEANUP
@@ -393,19 +393,19 @@ exp: foo { $$; } foo { $2; } foo
AT_BISON_CHECK([-fcaret input.y], [1], [], AT_BISON_CHECK([-fcaret input.y], [1], [],
[[input.y:5.12-13: error: $$ for the midrule at $2 of 'exp' has no declared type [[input.y:5.12-13: error: $$ for the midrule at $2 of 'exp' has no declared type
exp: foo { $$; } foo { $2; } foo exp: foo { $$; } foo { $2; } foo
^^ ^~
input.y:5.24-25: error: $2 of 'exp' has no declared type input.y:5.24-25: error: $2 of 'exp' has no declared type
exp: foo { $$; } foo { $2; } foo exp: foo { $$; } foo { $2; } foo
^^ ^~
input.y:5.6-32: warning: type clash on default action: <bar> != <> [-Wother] input.y:5.6-32: warning: type clash on default action: <bar> != <> [-Wother]
exp: foo { $$; } foo { $2; } foo exp: foo { $$; } foo { $2; } foo
^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~
input.y:6.6-8: warning: type clash on default action: <bar> != <> [-Wother] input.y:6.6-8: warning: type clash on default action: <bar> != <> [-Wother]
| foo | foo
^^^ ^~~
input.y:7.6-11: warning: empty rule for typed nonterminal, and no action [-Wother] input.y:7.6-11: warning: empty rule for typed nonterminal, and no action [-Wother]
| %empty | %empty
^^^^^^ ^~~~~~
]]) ]])
AT_CLEANUP AT_CLEANUP
@@ -464,133 +464,133 @@ AT_BISON_CHECK(m4_ifval([$2], [--warnings=midrule-values ])[-fcaret input.y],
[0], [], [0], [],
[[input.y:12.10-32: warning: unset value: $][$ [-Wother] [[input.y:12.10-32: warning: unset value: $][$ [-Wother]
a: INT | INT { } INT { } INT { }; a: INT | INT { } INT { } INT { };
^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~
input.y:12.10-12: warning: unused value: $][1 [-Wother] input.y:12.10-12: warning: unused value: $][1 [-Wother]
a: INT | INT { } INT { } INT { }; a: INT | INT { } INT { } INT { };
^^^ ^~~
input.y:12.18-20: warning: unused value: $][3 [-Wother] input.y:12.18-20: warning: unused value: $][3 [-Wother]
a: INT | INT { } INT { } INT { }; a: INT | INT { } INT { } INT { };
^^^ ^~~
input.y:12.26-28: warning: unused value: $][5 [-Wother] input.y:12.26-28: warning: unused value: $][5 [-Wother]
a: INT | INT { } INT { } INT { }; a: INT | INT { } INT { } INT { };
^^^ ^~~
input.y:13.10-15: warning: empty rule for typed nonterminal, and no action [-Wother] input.y:13.10-15: warning: empty rule for typed nonterminal, and no action [-Wother]
b: INT | %empty; b: INT | %empty;
^^^^^^ ^~~~~~
]]m4_ifval([$2], [[[input.y:14.14-20: warning: unset value: $][$ [-Wmidrule-values] ]]m4_ifval([$2], [[[input.y:14.14-20: warning: unset value: $][$ [-Wmidrule-values]
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; }; c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
^^^^^^^ ^~~~~~~
input.y:14.26-41: warning: unset value: $][$ [-Wmidrule-values] input.y:14.26-41: warning: unset value: $][$ [-Wmidrule-values]
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; }; c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~
]]])[[input.y:14.10-62: warning: unset value: $][$ [-Wother] ]]])[[input.y:14.10-62: warning: unset value: $][$ [-Wother]
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; }; c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input.y:14.22-24: warning: unused value: $][3 [-Wother] input.y:14.22-24: warning: unused value: $][3 [-Wother]
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; }; c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
^^^ ^~~
input.y:14.43-45: warning: unused value: $][5 [-Wother] input.y:14.43-45: warning: unused value: $][5 [-Wother]
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; }; c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
^^^ ^~~
]]m4_ifval([$2], [[[input.y:15.14-16: warning: unset value: $][$ [-Wmidrule-values] ]]m4_ifval([$2], [[[input.y:15.14-16: warning: unset value: $][$ [-Wmidrule-values]
d: INT | INT { } INT { $][1; } INT { $<integer>2; }; d: INT | INT { } INT { $][1; } INT { $<integer>2; };
^^^ ^~~
]]])[[input.y:15.10-49: warning: unset value: $][$ [-Wother] ]]])[[input.y:15.10-49: warning: unset value: $][$ [-Wother]
d: INT | INT { } INT { $][1; } INT { $<integer>2; }; d: INT | INT { } INT { $][1; } INT { $<integer>2; };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input.y:15.18-20: warning: unused value: $][3 [-Wother] input.y:15.18-20: warning: unused value: $][3 [-Wother]
d: INT | INT { } INT { $][1; } INT { $<integer>2; }; d: INT | INT { } INT { $][1; } INT { $<integer>2; };
^^^ ^~~
input.y:15.30-32: warning: unused value: $][5 [-Wother] input.y:15.30-32: warning: unused value: $][5 [-Wother]
d: INT | INT { } INT { $][1; } INT { $<integer>2; }; d: INT | INT { } INT { $][1; } INT { $<integer>2; };
^^^ ^~~
input.y:16.10-37: warning: unset value: $][$ [-Wother] input.y:16.10-37: warning: unset value: $][$ [-Wother]
e: INT | INT { } INT { } INT { $][1; }; e: INT | INT { } INT { } INT { $][1; };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
input.y:16.18-20: warning: unused value: $][3 [-Wother] input.y:16.18-20: warning: unused value: $][3 [-Wother]
e: INT | INT { } INT { } INT { $][1; }; e: INT | INT { } INT { } INT { $][1; };
^^^ ^~~
input.y:16.27-29: warning: unused value: $][5 [-Wother] input.y:16.27-29: warning: unused value: $][5 [-Wother]
e: INT | INT { } INT { } INT { $][1; }; e: INT | INT { } INT { } INT { $][1; };
^^^ ^~~
input.y:18.10-58: warning: unset value: $][$ [-Wother] input.y:18.10-58: warning: unset value: $][$ [-Wother]
g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { }; g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input.y:18.10-12: warning: unused value: $][1 [-Wother] input.y:18.10-12: warning: unused value: $][1 [-Wother]
g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { }; g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
^^^ ^~~
]]m4_ifval([$2], [[[input.y:18.14-29: warning: unused value: $][2 [-Wmidrule-values] ]]m4_ifval([$2], [[[input.y:18.14-29: warning: unused value: $][2 [-Wmidrule-values]
g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { }; g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~
]]])[[input.y:18.31-33: warning: unused value: $][3 [-Wother] ]]])[[input.y:18.31-33: warning: unused value: $][3 [-Wother]
g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { }; g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
^^^ ^~~
]]m4_ifval([$2], [[[input.y:18.35-50: warning: unused value: $][4 [-Wmidrule-values] ]]m4_ifval([$2], [[[input.y:18.35-50: warning: unused value: $][4 [-Wmidrule-values]
g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { }; g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~
]]])[[input.y:18.52-54: warning: unused value: $][5 [-Wother] ]]])[[input.y:18.52-54: warning: unused value: $][5 [-Wother]
g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { }; g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
^^^ ^~~
input.y:19.10-72: warning: unset value: $][$ [-Wother] input.y:19.10-72: warning: unset value: $][$ [-Wother]
h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { }; h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input.y:19.10-12: warning: unused value: $][1 [-Wother] input.y:19.10-12: warning: unused value: $][1 [-Wother]
h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { }; h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
^^^ ^~~
input.y:19.31-33: warning: unused value: $][3 [-Wother] input.y:19.31-33: warning: unused value: $][3 [-Wother]
h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { }; h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
^^^ ^~~
]]m4_ifval([$2], [[[input.y:19.35-64: warning: unused value: $][4 [-Wmidrule-values] ]]m4_ifval([$2], [[[input.y:19.35-64: warning: unused value: $][4 [-Wmidrule-values]
h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { }; h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
]]])[[input.y:19.66-68: warning: unused value: $][5 [-Wother] ]]])[[input.y:19.66-68: warning: unused value: $][5 [-Wother]
h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { }; h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
^^^ ^~~
]]m4_ifval([$2], [[[input.y:21.18-37: warning: unused value: $][3 [-Wmidrule-values] ]]m4_ifval([$2], [[[input.y:21.18-37: warning: unused value: $][3 [-Wmidrule-values]
j: INT | INT INT { $<integer>$ = 1; } { $][$ = $][1 + $][2; }; j: INT | INT INT { $<integer>$ = 1; } { $][$ = $][1 + $][2; };
^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~
]]])[[input.y:22.10-68: warning: unset value: $][$ [-Wother] ]]])[[input.y:22.10-68: warning: unset value: $][$ [-Wother]
k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { }; k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input.y:22.10-12: warning: unused value: $][1 [-Wother] input.y:22.10-12: warning: unused value: $][1 [-Wother]
k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { }; k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
^^^ ^~~
input.y:22.14-16: warning: unused value: $][2 [-Wother] input.y:22.14-16: warning: unused value: $][2 [-Wother]
k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { }; k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
^^^ ^~~
]]m4_ifval([$2], [[[input.y:22.35-64: warning: unused value: $][4 [-Wmidrule-values] ]]m4_ifval([$2], [[[input.y:22.35-64: warning: unused value: $][4 [-Wmidrule-values]
k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { }; k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
]]])[[input.y:25.23-25: warning: unset value: $][$ [-Wother] ]]])[[input.y:25.23-25: warning: unset value: $][$ [-Wother]
n: INT | INT <integer>{ } INT <integer>{ } INT { }; n: INT | INT <integer>{ } INT <integer>{ } INT { };
^^^ ^~~
input.y:25.40-42: warning: unset value: $][$ [-Wother] input.y:25.40-42: warning: unset value: $][$ [-Wother]
n: INT | INT <integer>{ } INT <integer>{ } INT { }; n: INT | INT <integer>{ } INT <integer>{ } INT { };
^^^ ^~~
input.y:25.10-50: warning: unset value: $][$ [-Wother] input.y:25.10-50: warning: unset value: $][$ [-Wother]
n: INT | INT <integer>{ } INT <integer>{ } INT { }; n: INT | INT <integer>{ } INT <integer>{ } INT { };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input.y:25.10-12: warning: unused value: $][1 [-Wother] input.y:25.10-12: warning: unused value: $][1 [-Wother]
n: INT | INT <integer>{ } INT <integer>{ } INT { }; n: INT | INT <integer>{ } INT <integer>{ } INT { };
^^^ ^~~
input.y:25.23-25: warning: unused value: $][2 [-Wother] input.y:25.23-25: warning: unused value: $][2 [-Wother]
n: INT | INT <integer>{ } INT <integer>{ } INT { }; n: INT | INT <integer>{ } INT <integer>{ } INT { };
^^^ ^~~
input.y:25.27-29: warning: unused value: $][3 [-Wother] input.y:25.27-29: warning: unused value: $][3 [-Wother]
n: INT | INT <integer>{ } INT <integer>{ } INT { }; n: INT | INT <integer>{ } INT <integer>{ } INT { };
^^^ ^~~
input.y:25.40-42: warning: unused value: $][4 [-Wother] input.y:25.40-42: warning: unused value: $][4 [-Wother]
n: INT | INT <integer>{ } INT <integer>{ } INT { }; n: INT | INT <integer>{ } INT <integer>{ } INT { };
^^^ ^~~
input.y:25.44-46: warning: unused value: $][5 [-Wother] input.y:25.44-46: warning: unused value: $][5 [-Wother]
n: INT | INT <integer>{ } INT <integer>{ } INT { }; n: INT | INT <integer>{ } INT <integer>{ } INT { };
^^^ ^~~
input.y:26.23-25: warning: unset value: $][$ [-Wother] input.y:26.23-25: warning: unset value: $][$ [-Wother]
o: INT | INT <integer>{ } INT <integer>{ } INT { $][$ = $][1 + $][2 + $][3 + $][4 + $][5; }; o: INT | INT <integer>{ } INT <integer>{ } INT { $][$ = $][1 + $][2 + $][3 + $][4 + $][5; };
^^^ ^~~
input.y:26.40-42: warning: unset value: $][$ [-Wother] input.y:26.40-42: warning: unset value: $][$ [-Wother]
o: INT | INT <integer>{ } INT <integer>{ } INT { $][$ = $][1 + $][2 + $][3 + $][4 + $][5; }; o: INT | INT <integer>{ } INT <integer>{ } INT { $][$ = $][1 + $][2 + $][3 + $][4 + $][5; };
^^^ ^~~
]]) ]])
]) ])
@@ -633,19 +633,19 @@ BAR:
AT_BISON_CHECK([-fcaret input.y], [1], [], AT_BISON_CHECK([-fcaret input.y], [1], [],
[[input.y:2.8-10: error: symbol FOO redeclared as a nonterminal [[input.y:2.8-10: error: symbol FOO redeclared as a nonterminal
%nterm FOO BAR %nterm FOO BAR
^^^ ^~~
input.y:1.8-10: previous definition input.y:1.8-10: previous definition
%token FOO %token FOO
^^^ ^~~
input.y:3.8-10: error: symbol BAR redeclared as a token input.y:3.8-10: error: symbol BAR redeclared as a token
%token BAR %token BAR
^^^ ^~~
input.y:2.12-14: previous definition input.y:2.12-14: previous definition
%nterm FOO BAR %nterm FOO BAR
^^^ ^~~
input.y:5.1-3: error: rule given for FOO, which is a token input.y:5.1-3: error: rule given for FOO, which is a token
FOO: BAR FOO: BAR
^^^ ^~~
]]) ]])
AT_CLEANUP AT_CLEANUP
@@ -678,40 +678,40 @@ start: %empty;
AT_BISON_CHECK([-fcaret input.y], [1], [], AT_BISON_CHECK([-fcaret input.y], [1], [],
[[input.y:1.13-29: error: %destructor redeclaration for <> [[input.y:1.13-29: error: %destructor redeclaration for <>
%destructor { destroy ($$); } <> <> %destructor { destroy ($$); } <> <>
^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~
input.y:1.13-29: previous declaration input.y:1.13-29: previous declaration
%destructor { destroy ($$); } <> <> %destructor { destroy ($$); } <> <>
^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~
input.y:2.10-24: error: %printer redeclaration for <> input.y:2.10-24: error: %printer redeclaration for <>
%printer { print ($$); } <> <> %printer { print ($$); } <> <>
^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~
input.y:2.10-24: previous declaration input.y:2.10-24: previous declaration
%printer { print ($$); } <> <> %printer { print ($$); } <> <>
^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~
input.y:4.13-29: error: %destructor redeclaration for <> input.y:4.13-29: error: %destructor redeclaration for <>
%destructor { destroy ($$); } <> %destructor { destroy ($$); } <>
^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~
input.y:1.13-29: previous declaration input.y:1.13-29: previous declaration
%destructor { destroy ($$); } <> <> %destructor { destroy ($$); } <> <>
^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~
input.y:5.10-24: error: %printer redeclaration for <> input.y:5.10-24: error: %printer redeclaration for <>
%printer { print ($$); } <> %printer { print ($$); } <>
^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~
input.y:2.10-24: previous declaration input.y:2.10-24: previous declaration
%printer { print ($$); } <> <> %printer { print ($$); } <> <>
^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~
input.y:11.13-29: error: %destructor redeclaration for <> input.y:11.13-29: error: %destructor redeclaration for <>
%destructor { destroy ($$); } <>; %destructor { destroy ($$); } <>;
^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~
input.y:1.13-29: previous declaration input.y:1.13-29: previous declaration
%destructor { destroy ($$); } <> <> %destructor { destroy ($$); } <> <>
^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~
input.y:12.10-24: error: %printer redeclaration for <> input.y:12.10-24: error: %printer redeclaration for <>
%printer { print ($$); } <>; %printer { print ($$); } <>;
^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~
input.y:2.10-24: previous declaration input.y:2.10-24: previous declaration
%printer { print ($$); } <> <> %printer { print ($$); } <> <>
^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~
]]) ]])
]) ])
@@ -781,16 +781,16 @@ exp: bar;
AT_BISON_CHECK([-fcaret input.y], [1], [], AT_BISON_CHECK([-fcaret input.y], [1], [],
[[input.y:2.16-18: error: symbol bar is used, but is not defined as a token and has no rules [[input.y:2.16-18: error: symbol bar is used, but is not defined as a token and has no rules
%destructor {} bar %destructor {} bar
^^^ ^~~
input.y:1.17-19: warning: symbol baz is used, but is not defined as a token and has no rules [-Wother] input.y:1.17-19: warning: symbol baz is used, but is not defined as a token and has no rules [-Wother]
%printer {} foo baz %printer {} foo baz
^^^ ^~~
input.y:1.13-15: warning: symbol foo is used, but is not defined as a token and has no rules [-Wother] input.y:1.13-15: warning: symbol foo is used, but is not defined as a token and has no rules [-Wother]
%printer {} foo baz %printer {} foo baz
^^^ ^~~
input.y:3.13-15: warning: symbol qux is used, but is not defined as a token and has no rules [-Wother] input.y:3.13-15: warning: symbol qux is used, but is not defined as a token and has no rules [-Wother]
%type <foo> qux %type <foo> qux
^^^ ^~~
]]) ]])
AT_CLEANUP AT_CLEANUP
@@ -910,13 +910,13 @@ tagged: { } ;
AT_BISON_CHECK([-fcaret input.y], [0], [], AT_BISON_CHECK([-fcaret input.y], [0], [],
[[input.y:6.8-45: warning: unset value: $$ [-Wother] [[input.y:6.8-45: warning: unset value: $$ [-Wother]
start: end end tagged tagged { $<tag>1; $3; } ; start: end end tagged tagged { $<tag>1; $3; } ;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input.y:6.12-14: warning: unused value: $2 [-Wother] input.y:6.12-14: warning: unused value: $2 [-Wother]
start: end end tagged tagged { $<tag>1; $3; } ; start: end end tagged tagged { $<tag>1; $3; } ;
^^^ ^~~
input.y:7.6-8: warning: unset value: $$ [-Wother] input.y:7.6-8: warning: unset value: $$ [-Wother]
end: { } ; end: { } ;
^^^ ^~~
]]) ]])
AT_DATA([[input.y]], AT_DATA([[input.y]],
@@ -957,13 +957,13 @@ end: { } ;
AT_BISON_CHECK([-fcaret input.y], [0], [], AT_BISON_CHECK([-fcaret input.y], [0], [],
[[input.y:6.8-22: warning: unset value: $$ [-Wother] [[input.y:6.8-22: warning: unset value: $$ [-Wother]
start: end end { $1; } ; start: end end { $1; } ;
^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~
input.y:6.12-14: warning: unused value: $2 [-Wother] input.y:6.12-14: warning: unused value: $2 [-Wother]
start: end end { $1; } ; start: end end { $1; } ;
^^^ ^~~
input.y:7.6-8: warning: unset value: $$ [-Wother] input.y:7.6-8: warning: unset value: $$ [-Wother]
end: { } ; end: { } ;
^^^ ^~~
]]) ]])
AT_CLEANUP AT_CLEANUP
@@ -1014,13 +1014,13 @@ exp: FOO BAR;
AT_BISON_CHECK([-fcaret input.y], [1], [], AT_BISON_CHECK([-fcaret input.y], [1], [],
[[input.y:2.17-21: warning: symbol "foo" used more than once as a literal string [-Wother] [[input.y:2.17-21: warning: symbol "foo" used more than once as a literal string [-Wother]
BAR 42 "foo" BAR 42 "foo"
^^^^^ ^~~~~
input.y:2.10-12: error: user token number 42 redeclaration for BAR input.y:2.10-12: error: user token number 42 redeclaration for BAR
BAR 42 "foo" BAR 42 "foo"
^^^ ^~~
input.y:1.8-10: previous declaration for FOO input.y:1.8-10: previous declaration for FOO
%token FOO 42 "foo" %token FOO 42 "foo"
^^^ ^~~
]]) ]])
AT_CLEANUP AT_CLEANUP
@@ -1048,10 +1048,10 @@ exp: foo;
]], ]],
[[input.y:3.7-11: error: %type redeclaration for foo [[input.y:3.7-11: error: %type redeclaration for foo
%type <baz> foo %type <baz> foo
^^^^^ ^~~~~
input.y:2.7-11: previous declaration input.y:2.7-11: previous declaration
%type <bar> "foo" %type <bar> "foo"
^^^^^ ^~~~~
]]) ]])
AT_TEST([[%token foo "foo" AT_TEST([[%token foo "foo"
@@ -1062,10 +1062,10 @@ exp: foo;
]], ]],
[[input.y:3.10-14: error: %printer redeclaration for foo [[input.y:3.10-14: error: %printer redeclaration for foo
%printer {baz} foo %printer {baz} foo
^^^^^ ^~~~~
input.y:2.10-14: previous declaration input.y:2.10-14: previous declaration
%printer {bar} "foo" %printer {bar} "foo"
^^^^^ ^~~~~
]]) ]])
AT_TEST([[%token foo "foo" AT_TEST([[%token foo "foo"
@@ -1076,10 +1076,10 @@ exp: foo;
]], ]],
[[input.y:3.13-17: error: %destructor redeclaration for foo [[input.y:3.13-17: error: %destructor redeclaration for foo
%destructor {baz} foo %destructor {baz} foo
^^^^^ ^~~~~
input.y:2.13-17: previous declaration input.y:2.13-17: previous declaration
%destructor {bar} "foo" %destructor {bar} "foo"
^^^^^ ^~~~~
]]) ]])
AT_TEST([[%token foo "foo" AT_TEST([[%token foo "foo"
@@ -1090,10 +1090,10 @@ exp: foo;
]], ]],
[[input.y:3.1-5: error: %left redeclaration for foo [[input.y:3.1-5: error: %left redeclaration for foo
%left foo %left foo
^^^^^ ^~~~~
input.y:2.1-5: previous declaration input.y:2.1-5: previous declaration
%left "foo" %left "foo"
^^^^^ ^~~~~
]]) ]])
# This time, declare the alias after its use. # This time, declare the alias after its use.
@@ -1107,10 +1107,10 @@ exp: foo;
]], ]],
[[input.y:2.1-5: error: %left redeclaration for foo [[input.y:2.1-5: error: %left redeclaration for foo
%left foo %left foo
^^^^^ ^~~~~
input.y:1.1-5: previous declaration input.y:1.1-5: previous declaration
%left "foo" %left "foo"
^^^^^ ^~~~~
]]) ]])
# Printer. # Printer.
@@ -1122,10 +1122,10 @@ exp: foo;
]], ]],
[[input.y:2.10-11: error: %printer redeclaration for foo [[input.y:2.10-11: error: %printer redeclaration for foo
%printer {} foo %printer {} foo
^^ ^~
input.y:1.10-11: previous declaration input.y:1.10-11: previous declaration
%printer {} "foo" %printer {} "foo"
^^ ^~
]]) ]])
# Destructor. # Destructor.
@@ -1137,10 +1137,10 @@ exp: foo;
]], ]],
[[input.y:2.13-14: error: %destructor redeclaration for foo [[input.y:2.13-14: error: %destructor redeclaration for foo
%destructor {} foo %destructor {} foo
^^ ^~
input.y:1.13-14: previous declaration input.y:1.13-14: previous declaration
%destructor {} "foo" %destructor {} "foo"
^^ ^~
]]) ]])
m4_popdef([AT_TEST]) m4_popdef([AT_TEST])
@@ -1170,7 +1170,7 @@ AT_DATA([input.y],
AT_BISON_CHECK([-fcaret input.y], [1], [], AT_BISON_CHECK([-fcaret input.y], [1], [],
[[input.y:1.1-2: error: syntax error, unexpected {...} [[input.y:1.1-2: error: syntax error, unexpected {...}
{} {}
^^ ^~
]]) ]])
@@ -1513,19 +1513,19 @@ start: %empty;
AT_BISON_CHECK([-fcaret -o input.c input.y], 1, [], AT_BISON_CHECK([-fcaret -o input.c input.y], 1, [],
[[input.y:1.10-2.0: error: missing '"' at end of line [[input.y:1.10-2.0: error: missing '"' at end of line
%token A "a %token A "a
^^ ^~
input.y:4.10-5.0: error: missing "'" at end of line input.y:4.10-5.0: error: missing "'" at end of line
%token C '1 %token C '1
^^ ^~
input.y:14.11-15.0: error: missing "'" at end of line input.y:14.11-15.0: error: missing "'" at end of line
%type <f> 'a %type <f> 'a
^^ ^~
input.y:16.11-17.0: error: missing '"' at end of line input.y:16.11-17.0: error: missing '"' at end of line
%type <f> "a %type <f> "a
^^ ^~
input.y:19.13-20.0: error: missing '}' at end of file input.y:19.13-20.0: error: missing '}' at end of file
%destructor { free ($$) %destructor { free ($$)
^^^^^^^^^^^ ^~~~~~~~~~~
input.y:20.1: error: syntax error, unexpected end of file input.y:20.1: error: syntax error, unexpected end of file
]]) ]])
@@ -1740,10 +1740,11 @@ start: %empty;
]]) ]])
AT_BISON_CHECK([[input-redefined.y]], [[1]], [], AT_BISON_CHECK([[input-redefined.y]], [[1]], [],
[[input-redefined.y:2.9-11: error: %define variable 'var' redefined [[input-redefined.y:2.1-20: error: %define variable 'var' redefined
input-redefined.y:1.9-11: previous definition input-redefined.y:1.1-20: previous definition
input-redefined.y:3.10-12: error: %define variable 'var' redefined input-redefined.y:3.2-21: error: %define variable 'var' redefined
input-redefined.y:2.9-11: previous definition input-redefined.y:2.1-20: previous definition
input-redefined.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
]]) ]])
AT_DATA([input-unused.y], AT_DATA([input-unused.y],
@@ -1753,7 +1754,7 @@ start: %empty;
]]) ]])
AT_BISON_CHECK([[input-unused.y]], [[1]], [], AT_BISON_CHECK([[input-unused.y]], [[1]], [],
[[input-unused.y:1.9-11: error: %define variable 'var' is not used [[input-unused.y:1.1-19: error: %define variable 'var' is not used
]]) ]])
AT_CLEANUP AT_CLEANUP
@@ -1797,8 +1798,9 @@ AT_DATA([[input-dg.y]],
start: %empty; start: %empty;
]]) ]])
AT_BISON_CHECK([[-Dvar=cmd-d input-dg.y]], [[1]], [], AT_BISON_CHECK([[-Dvar=cmd-d input-dg.y]], [[1]], [],
[[input-dg.y:1.9-11: error: %define variable 'var' redefined [[input-dg.y:1.1-18: error: %define variable 'var' redefined
<command line>:2: previous definition <command line>:2: previous definition
input-dg.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
]]) ]])
AT_DATA([[input-dg.y]], AT_DATA([[input-dg.y]],
@@ -1807,10 +1809,11 @@ AT_DATA([[input-dg.y]],
start: %empty; start: %empty;
]]) ]])
AT_BISON_CHECK([[-fcaret -Dvar=cmd-d input-dg.y]], [[1]], [], AT_BISON_CHECK([[-fcaret -Dvar=cmd-d input-dg.y]], [[1]], [],
[[input-dg.y:1.9-11: error: %define variable 'var' redefined [[input-dg.y:1.1-18: error: %define variable 'var' redefined
%define var "gram" %define var "gram"
^^^ ^~~~~~~~~~~~~~~~~~
<command line>:3: previous definition <command line>:3: previous definition
input-dg.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
]]) ]])
AT_DATA([[input-unused.y]], AT_DATA([[input-unused.y]],
@@ -1840,7 +1843,7 @@ start: %empty;
]]) ]])
AT_BISON_CHECK([[Input.y]], [1], [], AT_BISON_CHECK([[Input.y]], [1], [],
[[Input.y:3.9-25: error: invalid value for %define Boolean variable 'api.parser.public' [[Input.y:3.1-33: error: invalid value for %define Boolean variable 'api.parser.public'
]]) ]])
AT_CLEANUP AT_CLEANUP
@@ -1865,15 +1868,15 @@ start: TOK;
]]) ]])
AT_BISON_CHECK([[input.yy]], [0], [], AT_BISON_CHECK([[input.yy]], [0], [],
[[input.yy:2.9-25: warning: %define variable 'api.location.type' requires '{...}' values [-Wdeprecated] [[input.yy:2.$3: warning: %define variable 'api.location.type' requires '{...}' values [-Wdeprecated]
input.yy:4.9-18: warning: %define variable 'api.prefix' requires '{...}' values [-Wdeprecated] input.yy:4.$3: warning: %define variable 'api.prefix' requires '{...}' values [-Wdeprecated]
input.yy:5.9-24: warning: %define variable 'api.token.prefix' requires '{...}' values [-Wdeprecated] input.yy:5.$3: warning: %define variable 'api.token.prefix' requires '{...}' values [-Wdeprecated]
input.yy:3.9-21: warning: %define variable 'api.namespace' requires '{...}' values [-Wdeprecated] input.yy:3.$3: warning: %define variable 'api.namespace' requires '{...}' values [-Wdeprecated]
]]) ]])
]) ])
AT_TEST([], []) AT_TEST([], [], [1-30])
AT_TEST(["], ["]) AT_TEST(["], ["], [1-32])
m4_popdef([AT_TEST]) m4_popdef([AT_TEST])
AT_CLEANUP AT_CLEANUP
@@ -1897,11 +1900,11 @@ exp: %empty
]]) ]])
AT_BISON_CHECK([[input.y]], [0], [], AT_BISON_CHECK([[input.y]], [0], [],
[[input.y:5.9-15: warning: %define variable 'lr.type' requires keyword values [-Wdeprecated] [[input.y:5.1-40: warning: %define variable 'lr.type' requires keyword values [-Wdeprecated]
input.y:3.9-28: warning: %define variable 'lr.default-reduction' requires keyword values [-Wdeprecated] input.y:3.1-40: warning: %define variable 'lr.default-reduction' requires keyword values [-Wdeprecated]
input.y:4.9-33: warning: %define variable 'lr.keep-unreachable-state' requires keyword values [-Wdeprecated] input.y:4.1-40: warning: %define variable 'lr.keep-unreachable-state' requires keyword values [-Wdeprecated]
input.y:2.9-21: warning: %define variable 'api.push-pull' requires keyword values [-Wdeprecated] input.y:2.1-40: warning: %define variable 'api.push-pull' requires keyword values [-Wdeprecated]
input.y:1.9-16: warning: %define variable 'api.pure' requires keyword values [-Wdeprecated] input.y:1.1-38: warning: %define variable 'api.pure' requires keyword values [-Wdeprecated]
]]) ]])
]) ])
@@ -1929,12 +1932,12 @@ AT_DATA([[input.y]],
start: %empty; start: %empty;
]]) ]])
AT_BISON_CHECK([[-fcaret input.y]], [[1]], [[]], AT_BISON_CHECK([[-fcaret input.y]], [[1]], [[]],
[[input.y:1.9-28: error: invalid value for %define variable 'lr.default-reduction': 'bogus' [[input.y:1.1-34: error: invalid value for %define variable 'lr.default-reduction': 'bogus'
%define lr.default-reduction bogus %define lr.default-reduction bogus
^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input.y:1.9-28: accepted value: 'most' input.y:1.1-34: accepted value: 'most'
input.y:1.9-28: accepted value: 'consistent' input.y:1.1-34: accepted value: 'consistent'
input.y:1.9-28: accepted value: 'accepting' input.y:1.1-34: accepted value: 'accepting'
]]) ]])
# Back-end. # Back-end.
@@ -1944,12 +1947,12 @@ AT_DATA([[input.y]],
start: %empty; start: %empty;
]]) ]])
AT_BISON_CHECK([[-fcaret input.y]], [[1]], [[]], AT_BISON_CHECK([[-fcaret input.y]], [[1]], [[]],
[[input.y:1.9-21: error: invalid value for %define variable 'api.push-pull': 'neither' [[input.y:1.1-29: error: invalid value for %define variable 'api.push-pull': 'neither'
%define api.push-pull neither %define api.push-pull neither
^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input.y:1.9-21: accepted value: 'pull' input.y:1.1-29: accepted value: 'pull'
input.y:1.9-21: accepted value: 'push' input.y:1.1-29: accepted value: 'push'
input.y:1.9-21: accepted value: 'both' input.y:1.1-29: accepted value: 'both'
]]) ]])
AT_CLEANUP AT_CLEANUP
@@ -1970,9 +1973,9 @@ AT_DATA([[input.y]],
start: %empty; start: %empty;
]]) ]])
AT_BISON_CHECK([[-fcaret input.y]], [[1]], [[]], AT_BISON_CHECK([[-fcaret input.y]], [[1]], [[]],
[[input.y:3.9-25: error: %define variable 'api.location.file' requires 'none' or '"..."' values [[input.y:3.1-33: error: %define variable 'api.location.file' requires 'none' or '"..."' values
%define api.location.file {bogus} %define api.location.file {bogus}
^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
]]) ]])
AT_CLEANUP AT_CLEANUP
@@ -1996,27 +1999,28 @@ AT_DATA([[input.y]],
start: %empty; start: %empty;
]]) ]])
AT_BISON_CHECK([[-fcaret input.y]], [1], [], AT_BISON_CHECK([[-fcaret input.y]], [1], [],
[[input.y:1.9-21: warning: deprecated directive, use '%define api.push-pull both' [-Wdeprecated] [[input.y:1.1-26: warning: deprecated directive, use '%define api.push-pull both' [-Wdeprecated]
%define api.push_pull both %define api.push_pull both
^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~
input.y:2.9-34: warning: deprecated directive, use '%define lr.keep-unreachable-state maybe' [-Wdeprecated] input.y:2.1-40: warning: deprecated directive, use '%define lr.keep-unreachable-state maybe' [-Wdeprecated]
%define lr.keep_unreachable_states maybe %define lr.keep_unreachable_states maybe
^^^^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input.y:3.9-17: warning: deprecated directive, use '%define api.namespace {foo}' [-Wdeprecated] input.y:3.1-23: warning: deprecated directive, use '%define api.namespace {foo}' [-Wdeprecated]
%define namespace "foo" %define namespace "foo"
^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~
input.y:4.9-21: error: %define variable 'api.namespace' redefined input.y:4.1-27: error: %define variable 'api.namespace' redefined
%define api.namespace {foo} %define api.namespace {foo}
^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~
input.y:3.9-17: previous definition input.y:3.1-23: previous definition
%define namespace "foo" %define namespace "foo"
^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~
input.y:5.9-15: warning: deprecated directive, use '%define api.value.type variant' [-Wdeprecated] input.y:5.1-15: warning: deprecated directive, use '%define api.value.type variant' [-Wdeprecated]
%define variant %define variant
^^^^^^^ ^~~~~~~~~~~~~~~
input.y:6.9-25: warning: deprecated directive, use '%define api.parser.class {parser}' [-Wdeprecated] input.y:6.1-34: warning: deprecated directive, use '%define api.parser.class {parser}' [-Wdeprecated]
%define parser_class_name {parser} %define parser_class_name {parser}
^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
]]) ]])
AT_CLEANUP AT_CLEANUP
@@ -2028,11 +2032,11 @@ AT_CLEANUP
AT_SETUP([[Unused %define api.pure]]) AT_SETUP([[Unused %define api.pure]])
# AT_CHECK_API_PURE(DECLS, VALUE) # AT_TEST(DECLS, VALUE, LOCATION)
# ------------------------------- # -------------------------------
# Make sure Bison reports that '%define api.pure VALUE' is unused when DECLS # Make sure Bison reports that '%define api.pure VALUE' is unused when DECLS
# are specified. # are specified.
m4_define([AT_CHECK_API_PURE], m4_pushdef([AT_TEST],
[ [
AT_DATA([[input.y]], AT_DATA([[input.y]],
[[%define api.pure ]$2[ [[%define api.pure ]$2[
@@ -2042,16 +2046,18 @@ start: %empty;
]]) ]])
AT_BISON_CHECK([[input.y]], [[1]], [], AT_BISON_CHECK([[input.y]], [[1]], [],
[[input.y:1.9-16: error: %define variable 'api.pure' is not used [[input.y:]$3[: error: %define variable 'api.pure' is not used
]]) ]])
]) ])
AT_CHECK_API_PURE([[%language "c++"]], [[]]) AT_TEST([[%language "c++"]], [[]], [[1.1-16]])
AT_CHECK_API_PURE([[%language "c++"]], [[false]]) AT_TEST([[%language "c++"]], [[false]], [[1.1-22]])
AT_CHECK_API_PURE([[%language "c++" %glr-parser]], [[""]]) AT_TEST([[%language "c++" %glr-parser]], [[""]], [[1.1-19]])
AT_CHECK_API_PURE([[%language "c++" %glr-parser]], [[false]]) AT_TEST([[%language "c++" %glr-parser]], [[false]], [[1.1-22]])
AT_CHECK_API_PURE([[%language "java"]], [[true]]) AT_TEST([[%language "java"]], [[true]], [[1.1-21]])
AT_CHECK_API_PURE([[%language "java"]], [[false]]) AT_TEST([[%language "java"]], [[false]], [[1.1-22]])
m4_popdef([AT_TEST])
AT_CLEANUP AT_CLEANUP
@@ -2077,31 +2083,31 @@ start: %empty;
AT_BISON_CHECK([[input.y]], [1], [], AT_BISON_CHECK([[input.y]], [1], [],
[m4_foreach([b4_arg], m4_dquote(m4_shift($@)), [m4_foreach([b4_arg], m4_dquote(m4_shift($@)),
[[input.y:3.9-21: error: ]b4_arg[ [b4_arg
]])]) ])])
]) ])
AT_CHECK_NAMESPACE_ERROR([[]], AT_CHECK_NAMESPACE_ERROR([[]],
[[namespace reference is empty]]) [[input.y:3.1-24: error: namespace reference is empty]])
AT_CHECK_NAMESPACE_ERROR([[ @tb@@tb@ @tb@ @tb@]], AT_CHECK_NAMESPACE_ERROR([[ @tb@@tb@ @tb@ @tb@]],
[[namespace reference is empty]]) [[input.y:3.1-57: error: namespace reference is empty]])
AT_CHECK_NAMESPACE_ERROR([[foo::::bar]], AT_CHECK_NAMESPACE_ERROR([[foo::::bar]],
[[namespace reference has consecutive "::"]]) [[input.y:3.1-34: error: namespace reference has consecutive "::"]])
AT_CHECK_NAMESPACE_ERROR([[foo:: @tb@::bar]], AT_CHECK_NAMESPACE_ERROR([[foo:: @tb@::bar]],
[[namespace reference has consecutive "::"]]) [[input.y:3.1-38: error: namespace reference has consecutive "::"]])
AT_CHECK_NAMESPACE_ERROR([[::::bar]], AT_CHECK_NAMESPACE_ERROR([[::::bar]],
[[namespace reference has consecutive "::"]]) [[input.y:3.1-31: error: namespace reference has consecutive "::"]])
AT_CHECK_NAMESPACE_ERROR([[:: ::bar]], AT_CHECK_NAMESPACE_ERROR([[:: ::bar]],
[[namespace reference has consecutive "::"]]) [[input.y:3.1-32: error: namespace reference has consecutive "::"]])
AT_CHECK_NAMESPACE_ERROR([[foo::bar::@tb@::]], AT_CHECK_NAMESPACE_ERROR([[foo::bar::@tb@::]],
[[namespace reference has consecutive "::"]], [[input.y:3.1-43: error: namespace reference has consecutive "::"]],
[[namespace reference has a trailing "::"]]) [[input.y:3.1-43: error: namespace reference has a trailing "::"]])
AT_CHECK_NAMESPACE_ERROR([[foo::bar::]], AT_CHECK_NAMESPACE_ERROR([[foo::bar::]],
[[namespace reference has a trailing "::"]]) [[input.y:3.1-34: error: namespace reference has a trailing "::"]])
AT_CHECK_NAMESPACE_ERROR([[foo::bar:: @tb@]], AT_CHECK_NAMESPACE_ERROR([[foo::bar:: @tb@]],
[[namespace reference has a trailing "::"]]) [[input.y:3.1-41: error: namespace reference has a trailing "::"]])
AT_CHECK_NAMESPACE_ERROR([[::]], AT_CHECK_NAMESPACE_ERROR([[::]],
[[namespace reference has a trailing "::"]]) [[input.y:3.1-26: error: namespace reference has a trailing "::"]])
AT_CLEANUP AT_CLEANUP
@@ -2129,7 +2135,7 @@ AT_CHECK([[$PERL -e "print 'start: \'';" >> empty.y || exit 77]])
AT_BISON_CHECK([-fcaret empty.y], [1], [], AT_BISON_CHECK([-fcaret empty.y], [1], [],
[[empty.y:2.8-9: warning: empty character literal [-Wother] [[empty.y:2.8-9: warning: empty character literal [-Wother]
start: ''; start: '';
^^ ^~
empty.y:3.8-4.0: error: missing "'" at end of line empty.y:3.8-4.0: error: missing "'" at end of line
start: ' start: '
^ ^
@@ -2315,10 +2321,10 @@ AT_BISON_CHECK([[$2 -Wno-deprecated input.y]], [[1]], [[]],
]]) ]])
]) ])
AT_TEST([%define api.prefix {foo} %name-prefix "bar"], [], [input.y:1.9-18]) AT_TEST([%define api.prefix {foo} %name-prefix "bar"], [], [input.y:1.1-24])
AT_TEST([], [-Dapi.prefix={foo} -p bar], [<command line>:2]) AT_TEST([], [-Dapi.prefix={foo} -p bar], [<command line>:2])
AT_TEST([%name-prefix "bar"], [-Dapi.prefix={foo}], [<command line>:2]) AT_TEST([%name-prefix "bar"], [-Dapi.prefix={foo}], [<command line>:2])
AT_TEST([%define api.prefix {foo}], [-p bar], [input.y:1.9-18]) AT_TEST([%define api.prefix {foo}], [-p bar], [input.y:1.1-24])
m4_popdef([AT_TEST]) m4_popdef([AT_TEST])
@@ -2350,18 +2356,19 @@ AT_TEST([[%union foo {};
%define api.value.union.name foo]], %define api.value.union.name foo]],
[[input.y:3.8-10: error: %define variable 'api.value.union.name' redefined [[input.y:3.8-10: error: %define variable 'api.value.union.name' redefined
input.y:1.8-10: previous definition input.y:1.8-10: previous definition
input.y:4.9-28: error: %define variable 'api.value.union.name' redefined input.y:4.1-32: error: %define variable 'api.value.union.name' redefined
input.y:3.8-10: previous definition input.y:3.8-10: previous definition
input.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
]]) ]])
AT_TEST([[%define api.value.union.name {foo}]], AT_TEST([[%define api.value.union.name {foo}]],
[[input.y:1.9-28: error: %define variable 'api.value.union.name' requires keyword values [[input.y:1.1-34: error: %define variable 'api.value.union.name' requires keyword values
input.y:1.9-28: error: %define variable 'api.value.union.name' is not used input.y:1.1-34: error: %define variable 'api.value.union.name' is not used
]]) ]])
AT_TEST([[%define api.value.union.name "foo"]], AT_TEST([[%define api.value.union.name "foo"]],
[[input.y:1.9-28: error: %define variable 'api.value.union.name' requires keyword values [[input.y:1.1-34: error: %define variable 'api.value.union.name' requires keyword values
input.y:1.9-28: error: %define variable 'api.value.union.name' is not used input.y:1.1-34: error: %define variable 'api.value.union.name' is not used
]]) ]])
m4_popdef([AT_TEST]) m4_popdef([AT_TEST])
@@ -2506,27 +2513,94 @@ AT_DATA_GRAMMAR([[input.y]],
exp : '0' exp : '0'
]]) ]])
AT_BISON_CHECK([[input.y]], [[1]], [[]], AT_DATA([errors-all],
[[input.y:10.1-13: warning: deprecated directive: '%default_prec', use '%default-prec' [-Wdeprecated] [[input.y:10.1-13: warning: deprecated directive: '%default_prec', use '%default-prec' [-Wdeprecated]
fix-it:"input.y":{10:1-10:14}:"%default-prec"
input.y:11.1-14: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated] input.y:11.1-14: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
fix-it:"input.y":{11:1-11:15}:"%define parse.error verbose"
input.y:12.1-10: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated] input.y:12.1-10: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
fix-it:"input.y":{12:1-12:11}:"%expect-rr"
input.y:13.1-14: warning: deprecated directive: '%file-prefix =', use '%file-prefix' [-Wdeprecated] input.y:13.1-14: warning: deprecated directive: '%file-prefix =', use '%file-prefix' [-Wdeprecated]
input.y:14.1-15.2: warning: deprecated directive: '%file-prefix\n =', use '%file-prefix' [-Wdeprecated] fix-it:"input.y":{13:1-13:15}:"%file-prefix"
input.y:14.1-16.5: warning: duplicate directive: '%file-prefix\n =' [-Wother]
input.y:13.1-20: previous declaration [-Wother]
fix-it:"input.y":{14:1-16:6}:""
input.y:17.1-19: warning: deprecated directive: '%fixed-output_files', use '%fixed-output-files' [-Wdeprecated] input.y:17.1-19: warning: deprecated directive: '%fixed-output_files', use '%fixed-output-files' [-Wdeprecated]
input.y:18.1-19: warning: deprecated directive: '%fixed_output-files', use '%fixed-output-files' [-Wdeprecated] fix-it:"input.y":{17:1-17:20}:"%fixed-output-files"
input.y:20.1-13: warning: deprecated directive: '%name-prefix=', use '%define api.prefix' [-Wdeprecated] input.y:18.1-19: warning: duplicate directive: '%fixed_output-files' [-Wother]
input.y:17.1-19: previous declaration [-Wother]
fix-it:"input.y":{18:1-18:20}:""
input.y:19.1-19: warning: duplicate directive: '%fixed-output-files' [-Wother]
input.y:17.1-19: previous declaration [-Wother]
fix-it:"input.y":{19:1-19:20}:""
input.y:20.1-19: warning: deprecated directive: '%name-prefix= "foo"', use '%define api.prefix {foo}' [-Wdeprecated]
fix-it:"input.y":{20:1-20:20}:"%define api.prefix {foo}"
input.y:21.1-16: warning: deprecated directive: '%no-default_prec', use '%no-default-prec' [-Wdeprecated] input.y:21.1-16: warning: deprecated directive: '%no-default_prec', use '%no-default-prec' [-Wdeprecated]
fix-it:"input.y":{21:1-21:17}:"%no-default-prec"
input.y:22.1-16: warning: deprecated directive: '%no_default-prec', use '%no-default-prec' [-Wdeprecated] input.y:22.1-16: warning: deprecated directive: '%no_default-prec', use '%no-default-prec' [-Wdeprecated]
fix-it:"input.y":{22:1-22:17}:"%no-default-prec"
input.y:23.1-9: warning: deprecated directive: '%no_lines', use '%no-lines' [-Wdeprecated] input.y:23.1-9: warning: deprecated directive: '%no_lines', use '%no-lines' [-Wdeprecated]
fix-it:"input.y":{23:1-23:10}:"%no-lines"
input.y:24.1-9: warning: deprecated directive: '%output =', use '%output' [-Wdeprecated] input.y:24.1-9: warning: deprecated directive: '%output =', use '%output' [-Wdeprecated]
fix-it:"input.y":{24:1-24:10}:"%output"
input.y:25.1-12: warning: deprecated directive: '%pure_parser', use '%pure-parser' [-Wdeprecated] input.y:25.1-12: warning: deprecated directive: '%pure_parser', use '%pure-parser' [-Wdeprecated]
fix-it:"input.y":{25:1-25:13}:"%pure-parser"
input.y:26.1-12: warning: deprecated directive: '%token_table', use '%token-table' [-Wdeprecated] input.y:26.1-12: warning: deprecated directive: '%token_table', use '%token-table' [-Wdeprecated]
input.y:27.1-14: warning: deprecated directive: '%error-verbose', use '%define parse.error verbose' [-Wdeprecated] fix-it:"input.y":{26:1-26:13}:"%token-table"
input.y:27-6: error: %define variable 'parse.error' redefined input.y:27.1-14: error: %define variable 'parse.error' redefined
input.y:11-6: previous definition input.y:11.1-14: previous definition
input.y:29.1-12: warning: deprecated directive: '%name-prefix', use '%define api.prefix' [-Wdeprecated] fix-it:"input.y":{27:1-27:15}:""
input.y:29.1-18: warning: duplicate directive: '%name-prefix "bar"' [-Wother]
input.y:13.1-20: previous declaration [-Wother]
fix-it:"input.y":{29:1-29:19}:""
input.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
]]) ]])
AT_CHECK([cp errors-all experr])
AT_BISON_CHECK([[-ffixit input.y]], [[1]], [[]], [experr])
AT_CHECK([[sed -e '/^fix-it:/d' errors-all >experr]])
AT_BISON_CHECK([[input.y]], [[1]], [[]], [experr])
# Update the input file.
AT_CHECK([cp input.y input.y.orig])
AT_CHECK([sed -e '/fix-it/d' <errors-all >experr])
AT_CHECK([echo "bison: file 'input.y' was updated (backup: 'input.y~')" >>experr])
AT_BISON_CHECK([[--update input.y]], [[1]], [[]], [experr])
# Check the backup.
AT_CHECK([diff input.y.orig input.y~])
# Check the update.
AT_CHECK([cat input.y], [],
[[%code top {
/* Load config.h, and adjust to the compiler.
We used to do it here, but each time we add a new line,
we have to adjust all the line numbers in error messages.
It's simpler to use a constant include to a varying file. */
#include <testsuite.h>
}
%default-prec
%define parse.error verbose
%expect-rr 0
%file-prefix "foo"
%fixed-output-files
%define api.prefix {foo}
%no-default-prec
%no-default-prec
%no-lines
%output "foo"
%pure-parser
%token-table
%glr-parser
%%
exp : '0'
]])
AT_BISON_CHECK([[input.y]])
AT_CLEANUP AT_CLEANUP
@@ -2558,12 +2632,11 @@ AT_BISON_CHECK([[input.y]], [[1]], [[]],
input.y:11.15-24: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated] input.y:11.15-24: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
input.y:12.15-24: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated] input.y:12.15-24: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
input.y:13.1-14: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated] input.y:13.1-14: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
input.y:13.16-29: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated] input.y:13.16-29: error: %define variable 'parse.error' redefined
input.y:13.11-21: error: %define variable 'parse.error' redefined input.y:13.1-14: previous definition
input.y:13-6: previous definition input.y:14.16-29: error: %define variable 'parse.error' redefined
input.y:14.16-29: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated] input.y:13.16-29: previous definition
input.y:14.11-21: error: %define variable 'parse.error' redefined input.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
input.y:13.11-21: previous definition
]]) ]])
AT_CLEANUP AT_CLEANUP
@@ -2595,7 +2668,10 @@ AT_DATA_GRAMMAR([[input.y]],
]]) ]])
AT_BISON_CHECK([[input.y]], [[0]], [[]], AT_BISON_CHECK([[input.y]], [[0]], [[]],
[[input.y: warning: %expect-rr applies only to GLR parsers [-Wother] [[input.y:14.1-15.5: warning: duplicate directive: '%file-prefix' [-Wother]
input.y:13.1-18: previous declaration [-Wother]
input.y: warning: %expect-rr applies only to GLR parsers [-Wother]
input.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
]]) ]])
AT_CLEANUP AT_CLEANUP
@@ -2615,7 +2691,7 @@ exp: <int> {}
AT_BISON_CHECK([[-fcaret input.y]], [[0]], [[]], AT_BISON_CHECK([[-fcaret input.y]], [[0]], [[]],
[[input.y:10.6-13: warning: only midrule actions can be typed: int [-Wother] [[input.y:10.6-13: warning: only midrule actions can be typed: int [-Wother]
exp: <int> {} exp: <int> {}
^^^^^^^^ ^~~~~~~~
]]) ]])
AT_CLEANUP AT_CLEANUP
+3 -2
View File
@@ -707,8 +707,9 @@ if test "$POSIXLY_CORRECT_IS_EXPORTED" = false; then
# Build expected stderr up to and including the "warnings being # Build expected stderr up to and including the "warnings being
# treated as errors" message. # treated as errors" message.
]AT_DATA([[experr]], [$4])[ ]AT_DATA([[experr]], [$4])[
$PERL -pi -e 's{(.*): warning: (.*)\[-W(.*)\]$} $PERL -pi -e 's{(.*): warning:}{$][1: error:};' \
{$][1: error: $][2\@<:@-Werror=$][3@:>@}' experr -e 's{\[-W(.*)\]$}{@<:@-Werror=$][1@:>@}' \
experr
]AT_CHECK([[sed 's,.*/$,,' stderr 1>&2]], [[0]], [[]], [experr])[ ]AT_CHECK([[sed 's,.*/$,,' stderr 1>&2]], [[0]], [[]], [experr])[
# Now check --warnings=error. # Now check --warnings=error.
+48 -48
View File
@@ -254,16 +254,16 @@ exp:
AT_BISON_CHECK([-fcaret -o test.c test.y], 1, [], AT_BISON_CHECK([-fcaret -o test.c test.y], 1, [],
[[test.y:52.51-60: error: invalid reference: '$<ival>lo9' [[test.y:52.51-60: error: invalid reference: '$<ival>lo9'
| exp[x] '+' { $<ival>$ = $x; } [l] exp[r] { $$ = $<ival>lo9 + $r; } | exp[x] '+' { $<ival>$ = $x; } [l] exp[r] { $$ = $<ival>lo9 + $r; }
^^^^^^^^^^ ^~~~~~~~~~
test.y:52.3-68: symbol not found in production: lo9 test.y:52.3-68: symbol not found in production: lo9
| exp[x] '+' { $<ival>$ = $x; } [l] exp[r] { $$ = $<ival>lo9 + $r; } | exp[x] '+' { $<ival>$ = $x; } [l] exp[r] { $$ = $<ival>lo9 + $r; }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.y:53.51-60: warning: misleading reference: '$<ival>exp' [-Wother] test.y:53.51-60: warning: misleading reference: '$<ival>exp' [-Wother]
| exp[x] '-' { $<ival>$ = $x; } [l] exp[r] { $$ = $<ival>exp - $r; } | exp[x] '-' { $<ival>$ = $x; } [l] exp[r] { $$ = $<ival>exp - $r; }
^^^^^^^^^^ ^~~~~~~~~~
test.y:44.1-3: refers to: $exp at $$ test.y:44.1-3: refers to: $exp at $$
exp: exp:
^^^ ^~~
test.y:53.7: possibly meant: $x, hiding $exp at $1 test.y:53.7: possibly meant: $x, hiding $exp at $1
| exp[x] '-' { $<ival>$ = $x; } [l] exp[r] { $$ = $<ival>exp - $r; } | exp[x] '-' { $<ival>$ = $x; } [l] exp[r] { $$ = $<ival>exp - $r; }
^ ^
@@ -272,19 +272,19 @@ test.y:53.41: possibly meant: $r, hiding $exp at $4
^ ^
test.y:54.51-52: error: $l of 'exp' has no declared type test.y:54.51-52: error: $l of 'exp' has no declared type
| exp[x] '*' { $<ival>$ = $x; } [l] exp[r] { $$ = $l * $r; } | exp[x] '*' { $<ival>$ = $x; } [l] exp[r] { $$ = $l * $r; }
^^ ^~
test.y:57.40-43: error: invalid reference: '$r12' test.y:57.40-43: error: invalid reference: '$r12'
| exp[l] '^' exp[r] { $$ = power ($l, $r12); } | exp[l] '^' exp[r] { $$ = power ($l, $r12); }
^^^^ ^~~~
test.y:57.3-47: symbol not found in production: r12 test.y:57.3-47: symbol not found in production: r12
| exp[l] '^' exp[r] { $$ = power ($l, $r12); } | exp[l] '^' exp[r] { $$ = power ($l, $r12); }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.y:58.29-33: error: invalid reference: '$expo' test.y:58.29-33: error: invalid reference: '$expo'
| '(' exp ')' { $$ = $expo; } | '(' exp ')' { $$ = $expo; }
^^^^^ ^~~~~
test.y:58.3-46: symbol not found in production: expo test.y:58.3-46: symbol not found in production: expo
| '(' exp ')' { $$ = $expo; } | '(' exp ')' { $$ = $expo; }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
]]) ]])
AT_BISON_OPTION_POPDEFS AT_BISON_OPTION_POPDEFS
AT_CLEANUP AT_CLEANUP
@@ -423,121 +423,121 @@ test.y:45.41-46: possibly meant: $[then-a].f at $4
AT_BISON_CHECK([-fcaret -o test.c test.y], 1, [], AT_BISON_CHECK([-fcaret -o test.c test.y], 1, [],
[[test.y:24.36-41: error: invalid reference: '$cond1' [[test.y:24.36-41: error: invalid reference: '$cond1'
{ $if_stmt1 = new IfStmt($cond1, $then.f1, $else); }; { $if_stmt1 = new IfStmt($cond1, $then.f1, $else); };
^^^^^^ ^~~~~~
test.y:23.11-24.62: symbol not found in production: cond1 test.y:23.11-24.62: symbol not found in production: cond1
if_stmt1: IF expr[cond] THEN stmt[then] ELSE stmt.list[else] FI if_stmt1: IF expr[cond] THEN stmt[then] ELSE stmt.list[else] FI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.y:26.43-53: error: invalid reference: '$stmt.field' test.y:26.43-53: error: invalid reference: '$stmt.field'
{ $if_stmt2 = new IfStmt($cond, $stmt.field, 0); }; { $if_stmt2 = new IfStmt($cond, $stmt.field, 0); };
^^^^^^^^^^^ ^~~~~~~~~~~
test.y:25.11-26.60: symbol not found in production: stmt test.y:25.11-26.60: symbol not found in production: stmt
if_stmt2: IF expr[cond] THEN stmt[then] FI if_stmt2: IF expr[cond] THEN stmt[then] FI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.y:25.35-38: possibly meant: $then.field, hiding $stmt.field at $4 test.y:25.35-38: possibly meant: $then.field, hiding $stmt.field at $4
if_stmt2: IF expr[cond] THEN stmt[then] FI if_stmt2: IF expr[cond] THEN stmt[then] FI
^^^^ ^~~~
test.y:28.43-52: error: invalid reference: '$stmt.list' test.y:28.43-52: error: invalid reference: '$stmt.list'
{ $if_stmt3 = new IfStmt($cond, $stmt.list, 0); }; { $if_stmt3 = new IfStmt($cond, $stmt.list, 0); };
^^^^^^^^^^ ^~~~~~~~~~
test.y:27.11-28.59: symbol not found in production: stmt test.y:27.11-28.59: symbol not found in production: stmt
if_stmt3: IF expr[cond] THEN stmt.list FI if_stmt3: IF expr[cond] THEN stmt.list FI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.y:27.30-38: possibly meant: $[stmt.list] at $4 test.y:27.30-38: possibly meant: $[stmt.list] at $4
if_stmt3: IF expr[cond] THEN stmt.list FI if_stmt3: IF expr[cond] THEN stmt.list FI
^^^^^^^^^ ^~~~~~~~~
test.y:30.43-46: error: ambiguous reference: '$xyz' test.y:30.43-46: error: ambiguous reference: '$xyz'
{ $if_stmt4 = new IfStmt($cond, $xyz, $cond); }; { $if_stmt4 = new IfStmt($cond, $xyz, $cond); };
^^^^ ^~~~
test.y:29.35-37: refers to: $xyz at $4 test.y:29.35-37: refers to: $xyz at $4
if_stmt4: IF expr[cond] THEN stmt[xyz] ELSE stmt[xyz] FI if_stmt4: IF expr[cond] THEN stmt[xyz] ELSE stmt[xyz] FI
^^^ ^~~
test.y:29.50-52: refers to: $xyz at $6 test.y:29.50-52: refers to: $xyz at $6
if_stmt4: IF expr[cond] THEN stmt[xyz] ELSE stmt[xyz] FI if_stmt4: IF expr[cond] THEN stmt[xyz] ELSE stmt[xyz] FI
^^^ ^~~
test.y:32.43-52: error: invalid reference: '$stmt.list' test.y:32.43-52: error: invalid reference: '$stmt.list'
{ $if_stmt5 = new IfStmt($cond, $stmt.list, $else); }; { $if_stmt5 = new IfStmt($cond, $stmt.list, $else); };
^^^^^^^^^^ ^~~~~~~~~~
test.y:31.11-32.63: symbol not found in production: stmt test.y:31.11-32.63: symbol not found in production: stmt
if_stmt5: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI if_stmt5: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.y:31.40-43: possibly meant: $then, hiding $[stmt.list] at $4 test.y:31.40-43: possibly meant: $then, hiding $[stmt.list] at $4
if_stmt5: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI if_stmt5: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI
^^^^ ^~~~
test.y:31.61-64: possibly meant: $else, hiding $[stmt.list] at $6 test.y:31.61-64: possibly meant: $else, hiding $[stmt.list] at $6
if_stmt5: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI if_stmt5: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI
^^^^ ^~~~
test.y:34.43-58: error: invalid reference: '$stmt.list.field' test.y:34.43-58: error: invalid reference: '$stmt.list.field'
{ $if_stmt6 = new IfStmt($cond, $stmt.list.field, $else); }; { $if_stmt6 = new IfStmt($cond, $stmt.list.field, $else); };
^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~
test.y:33.11-34.69: symbol not found in production: stmt test.y:33.11-34.69: symbol not found in production: stmt
if_stmt6: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI if_stmt6: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.y:33.40-43: possibly meant: $then.field, hiding $[stmt.list].field at $4 test.y:33.40-43: possibly meant: $then.field, hiding $[stmt.list].field at $4
if_stmt6: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI if_stmt6: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI
^^^^ ^~~~
test.y:33.61-64: possibly meant: $else.field, hiding $[stmt.list].field at $6 test.y:33.61-64: possibly meant: $else.field, hiding $[stmt.list].field at $6
if_stmt6: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI if_stmt6: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI
^^^^ ^~~~
test.y:36.43-54: error: invalid reference: '$[stmt.list]' test.y:36.43-54: error: invalid reference: '$[stmt.list]'
{ $if_stmt7 = new IfStmt($cond, $[stmt.list].field, $else); }; { $if_stmt7 = new IfStmt($cond, $[stmt.list].field, $else); };
^^^^^^^^^^^^ ^~~~~~~~~~~~
test.y:35.11-36.71: symbol not found in production: stmt.list test.y:35.11-36.71: symbol not found in production: stmt.list
if_stmt7: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI if_stmt7: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.y:35.40-43: possibly meant: $then, hiding $[stmt.list] at $4 test.y:35.40-43: possibly meant: $then, hiding $[stmt.list] at $4
if_stmt7: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI if_stmt7: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI
^^^^ ^~~~
test.y:35.61-64: possibly meant: $else, hiding $[stmt.list] at $6 test.y:35.61-64: possibly meant: $else, hiding $[stmt.list] at $6
if_stmt7: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI if_stmt7: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI
^^^^ ^~~~
test.y:38.43-49: error: invalid reference: '$then.1' test.y:38.43-49: error: invalid reference: '$then.1'
{ $if_stmt8 = new IfStmt($cond, $then.1, $else); }; { $if_stmt8 = new IfStmt($cond, $then.1, $else); };
^^^^^^^ ^~~~~~~
test.y:37.11-38.60: symbol not found in production: then test.y:37.11-38.60: symbol not found in production: then
if_stmt8: IF expr[cond] THEN stmt.list[then.1] ELSE stmt.list[else] FI if_stmt8: IF expr[cond] THEN stmt.list[then.1] ELSE stmt.list[else] FI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.y:37.40-45: possibly meant: $[then.1] at $4 test.y:37.40-45: possibly meant: $[then.1] at $4
if_stmt8: IF expr[cond] THEN stmt.list[then.1] ELSE stmt.list[else] FI if_stmt8: IF expr[cond] THEN stmt.list[then.1] ELSE stmt.list[else] FI
^^^^^^ ^~~~~~
test.y:40.43-55: error: invalid reference: '$then.1.field' test.y:40.43-55: error: invalid reference: '$then.1.field'
{ $if_stmt9 = new IfStmt($cond, $then.1.field, $else); }; { $if_stmt9 = new IfStmt($cond, $then.1.field, $else); };
^^^^^^^^^^^^^ ^~~~~~~~~~~~~
test.y:39.11-40.66: symbol not found in production: then test.y:39.11-40.66: symbol not found in production: then
if_stmt9: IF expr[cond] THEN stmt.list[then.1] ELSE stmt.list[else] FI if_stmt9: IF expr[cond] THEN stmt.list[then.1] ELSE stmt.list[else] FI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.y:39.40-45: possibly meant: $[then.1].field at $4 test.y:39.40-45: possibly meant: $[then.1].field at $4
if_stmt9: IF expr[cond] THEN stmt.list[then.1] ELSE stmt.list[else] FI if_stmt9: IF expr[cond] THEN stmt.list[then.1] ELSE stmt.list[else] FI
^^^^^^ ^~~~~~
test.y:42.44-50: error: invalid reference: '$stmt.x' test.y:42.44-50: error: invalid reference: '$stmt.x'
{ $if_stmt10 = new IfStmt($cond, $stmt.x, 0); }; { $if_stmt10 = new IfStmt($cond, $stmt.x, 0); };
^^^^^^^ ^~~~~~~
test.y:41.12-42.57: symbol not found in production: stmt test.y:41.12-42.57: symbol not found in production: stmt
if_stmt10: IF expr[cond] THEN stmt[stmt.x] FI if_stmt10: IF expr[cond] THEN stmt[stmt.x] FI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.y:41.36-41: possibly meant: $[stmt.x].x, hiding $stmt.x at $4 test.y:41.36-41: possibly meant: $[stmt.x].x, hiding $stmt.x at $4
if_stmt10: IF expr[cond] THEN stmt[stmt.x] FI if_stmt10: IF expr[cond] THEN stmt[stmt.x] FI
^^^^^^ ^~~~~~
test.y:41.36-41: possibly meant: $[stmt.x] at $4 test.y:41.36-41: possibly meant: $[stmt.x] at $4
if_stmt10: IF expr[cond] THEN stmt[stmt.x] FI if_stmt10: IF expr[cond] THEN stmt[stmt.x] FI
^^^^^^ ^~~~~~
test.y:44.13-22: error: invalid reference: '$if-stmt-a' test.y:44.13-22: error: invalid reference: '$if-stmt-a'
{ $if-stmt-a = new IfStmt($cond, $then, $else); }; { $if-stmt-a = new IfStmt($cond, $then, $else); };
^^^^^^^^^^ ^~~~~~~~~~
test.y:43.12-44.59: symbol not found in production: if test.y:43.12-44.59: symbol not found in production: if
if-stmt-a: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI if-stmt-a: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.y:43.1-9: possibly meant: $[if-stmt-a] at $$ test.y:43.1-9: possibly meant: $[if-stmt-a] at $$
if-stmt-a: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI if-stmt-a: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI
^^^^^^^^^ ^~~~~~~~~
test.y:46.46-54: error: invalid reference: '$then-a.f' test.y:46.46-54: error: invalid reference: '$then-a.f'
{ $[if-stmt-b] = new IfStmt($cond, $then-a.f, $else); }; { $[if-stmt-b] = new IfStmt($cond, $then-a.f, $else); };
^^^^^^^^^ ^~~~~~~~~
test.y:45.12-46.65: symbol not found in production: then test.y:45.12-46.65: symbol not found in production: then
if-stmt-b: IF expr[cond] THEN if-stmt-a[then-a] ELSE stmt.list[else] FI if-stmt-b: IF expr[cond] THEN if-stmt-a[then-a] ELSE stmt.list[else] FI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.y:45.41-46: possibly meant: $[then-a].f at $4 test.y:45.41-46: possibly meant: $[then-a].f at $4
if-stmt-b: IF expr[cond] THEN if-stmt-a[then-a] ELSE stmt.list[else] FI if-stmt-b: IF expr[cond] THEN if-stmt-a[then-a] ELSE stmt.list[else] FI
^^^^^^ ^~~~~~
]]) ]])
AT_CLEANUP AT_CLEANUP
+1 -1
View File
@@ -154,7 +154,7 @@ start: ;
AT_BISON_OPTION_POPDEFS AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[input.y]], [[1]], [], AT_BISON_CHECK([[input.y]], [[1]], [],
[[input.y:2.9-21: error: %define variable 'api.push-pull' is not used [[input.y:2.1-26: error: %define variable 'api.push-pull' is not used
]]) ]])
AT_CLEANUP AT_CLEANUP
+15 -15
View File
@@ -134,31 +134,31 @@ AT_BISON_CHECK([[-fcaret input.y]], 0, [],
input.y: warning: 9 rules useless in grammar [-Wother] input.y: warning: 9 rules useless in grammar [-Wother]
input.y:6.1-8: warning: nonterminal useless in grammar: useless1 [-Wother] input.y:6.1-8: warning: nonterminal useless in grammar: useless1 [-Wother]
useless1: '1'; useless1: '1';
^^^^^^^^ ^~~~~~~~
input.y:7.1-8: warning: nonterminal useless in grammar: useless2 [-Wother] input.y:7.1-8: warning: nonterminal useless in grammar: useless2 [-Wother]
useless2: '2'; useless2: '2';
^^^^^^^^ ^~~~~~~~
input.y:8.1-8: warning: nonterminal useless in grammar: useless3 [-Wother] input.y:8.1-8: warning: nonterminal useless in grammar: useless3 [-Wother]
useless3: '3'; useless3: '3';
^^^^^^^^ ^~~~~~~~
input.y:9.1-8: warning: nonterminal useless in grammar: useless4 [-Wother] input.y:9.1-8: warning: nonterminal useless in grammar: useless4 [-Wother]
useless4: '4'; useless4: '4';
^^^^^^^^ ^~~~~~~~
input.y:10.1-8: warning: nonterminal useless in grammar: useless5 [-Wother] input.y:10.1-8: warning: nonterminal useless in grammar: useless5 [-Wother]
useless5: '5'; useless5: '5';
^^^^^^^^ ^~~~~~~~
input.y:11.1-8: warning: nonterminal useless in grammar: useless6 [-Wother] input.y:11.1-8: warning: nonterminal useless in grammar: useless6 [-Wother]
useless6: '6'; useless6: '6';
^^^^^^^^ ^~~~~~~~
input.y:12.1-8: warning: nonterminal useless in grammar: useless7 [-Wother] input.y:12.1-8: warning: nonterminal useless in grammar: useless7 [-Wother]
useless7: '7'; useless7: '7';
^^^^^^^^ ^~~~~~~~
input.y:13.1-8: warning: nonterminal useless in grammar: useless8 [-Wother] input.y:13.1-8: warning: nonterminal useless in grammar: useless8 [-Wother]
useless8: '8'; useless8: '8';
^^^^^^^^ ^~~~~~~~
input.y:14.1-8: warning: nonterminal useless in grammar: useless9 [-Wother] input.y:14.1-8: warning: nonterminal useless in grammar: useless9 [-Wother]
useless9: '9'; useless9: '9';
^^^^^^^^ ^~~~~~~~
]]) ]])
@@ -240,13 +240,13 @@ AT_BISON_CHECK([[-fcaret not-reduced.y]], 0, [],
not-reduced.y: warning: 3 rules useless in grammar [-Wother] not-reduced.y: warning: 3 rules useless in grammar [-Wother]
not-reduced.y:14.1-13: warning: nonterminal useless in grammar: not_reachable [-Wother] not-reduced.y:14.1-13: warning: nonterminal useless in grammar: not_reachable [-Wother]
not_reachable: useful { /* A not reachable action. */ } not_reachable: useful { /* A not reachable action. */ }
^^^^^^^^^^^^^ ^~~~~~~~~~~~~
not-reduced.y:17.1-14: warning: nonterminal useless in grammar: non_productive [-Wother] not-reduced.y:17.1-14: warning: nonterminal useless in grammar: non_productive [-Wother]
non_productive: non_productive useless_token non_productive: non_productive useless_token
^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~
not-reduced.y:11.6-57: warning: rule useless in grammar [-Wother] not-reduced.y:11.6-57: warning: rule useless in grammar [-Wother]
| non_productive { /* A non productive action. */ } | non_productive { /* A non productive action. */ }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
]]) ]])
AT_CHECK([[sed -n '/^Grammar/q;/^$/!p' not-reduced.output]], 0, AT_CHECK([[sed -n '/^Grammar/q;/^$/!p' not-reduced.output]], 0,
@@ -319,13 +319,13 @@ AT_BISON_CHECK([[-fcaret input.y]], 0, [],
input.y: warning: 3 rules useless in grammar [-Wother] input.y: warning: 3 rules useless in grammar [-Wother]
input.y:6.1-11: warning: nonterminal useless in grammar: underivable [-Wother] input.y:6.1-11: warning: nonterminal useless in grammar: underivable [-Wother]
underivable: indirection; underivable: indirection;
^^^^^^^^^^^ ^~~~~~~~~~~
input.y:7.1-11: warning: nonterminal useless in grammar: indirection [-Wother] input.y:7.1-11: warning: nonterminal useless in grammar: indirection [-Wother]
indirection: underivable; indirection: underivable;
^^^^^^^^^^^ ^~~~~~~~~~~
input.y:5.15-25: warning: rule useless in grammar [-Wother] input.y:5.15-25: warning: rule useless in grammar [-Wother]
exp: useful | underivable; exp: useful | underivable;
^^^^^^^^^^^ ^~~~~~~~~~~
]]) ]])
AT_CHECK([[sed -n '/^Grammar/q;/^$/!p' input.output]], 0, AT_CHECK([[sed -n '/^Grammar/q;/^$/!p' input.output]], 0,
+2 -2
View File
@@ -454,10 +454,10 @@ input.y:22.16-63: warning: symbol "\\'?\"\a\b\f\n\r\t\v\001\201\001\201??!" used
AT_BISON_CHECK([-fcaret -o input.c input.y], [[0]], [[]], AT_BISON_CHECK([-fcaret -o input.c input.y], [[0]], [[]],
[[input.y:22.8-14: warning: symbol SPECIAL redeclared [-Wother] [[input.y:22.8-14: warning: symbol SPECIAL redeclared [-Wother]
%token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!" %token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"
^^^^^^^ ^~~~~~~
input.y:22.16-63: warning: symbol "\\'?\"\a\b\f\n\r\t\v\001\201\001\201??!" used more than once as a literal string [-Wother] input.y:22.16-63: warning: symbol "\\'?\"\a\b\f\n\r\t\v\001\201\001\201??!" used more than once as a literal string [-Wother]
%token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!" %token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
]]) ]])
AT_COMPILE([input]) AT_COMPILE([input])
+2 -2
View File
@@ -32,7 +32,7 @@ exp: %empty;
]]) ]])
AT_BISON_CHECK([[input.y]], [[1]], [[]], AT_BISON_CHECK([[input.y]], [[1]], [[]],
[[input.y:2.9-22: error: '%union' and '%define api.value.type' cannot be used together [[input.y:2.1-38: error: '%union' and '%define api.value.type' cannot be used together
]]) ]])
AT_CLEANUP AT_CLEANUP
@@ -51,7 +51,7 @@ exp: %empty;
]]) ]])
AT_BISON_CHECK([[input.y]], [[1]], [[]], AT_BISON_CHECK([[input.y]], [[1]], [[]],
[[input.y:2.9-22: error: '%yacc' and '%define api.value.type "union"' cannot be used together [[input.y:2.1-28: error: '%yacc' and '%define api.value.type "union"' cannot be used together
]]) ]])
AT_CLEANUP AT_CLEANUP