warnings: introduce -Wprecedence

The new warning category "precedence" flags useless precedence and
associativity.  -Wprecedence can now be used, it is disabled by default.
The warnings about precedence and associativity are grouped into one, and
the testsuite was corrected accordingly.

* src/complain.h (warnings): Introduce "precedence".
* src/complain.c (warnings_print_categories): Adjust.
* src/getargs.c (warnings_args, warning_types): Likewise.
* src/symtab.h, src/symtab.c (print_associativity_warnings): Remove.
* src/symtab.h (register_assoc): Correct arguments.
* src/symtab.c (print_precedence_warnings): Print both warnings together.
* doc/bison.texi (Bison options): Document the warnings and provide an
example.
* tests/conflicts.at, tests/existing.at, tests/local.at,
* tests/regression.at: Adapt the testsuite for the new category
(-Wprecedence instead of -Wother where appropriate).
This commit is contained in:
Valentin Tolmer
2013-01-30 11:30:15 +01:00
committed by Akim Demaille
parent df1ca1b0de
commit cc2235ace2
12 changed files with 331 additions and 232 deletions

View File

@@ -377,9 +377,9 @@ exp: ;
%%
]])
AT_BISON_CHECK([-v -o input.c input.y], 0, [],
[[input.y:1.29-32: warning: useless associativity for "||" [-Wother]
input.y:2.29-32: warning: useless associativity for "<=" [-Wother]
AT_BISON_CHECK([-v -Wall -o input.c input.y], 0, [],
[[input.y:1.29-32: warning: useless precedence and associativity for "||" [-Wprecedence]
input.y:2.29-32: warning: useless precedence and associativity for "<=" [-Wprecedence]
]])
AT_CLEANUP
@@ -1147,10 +1147,10 @@ sr_conflict:
]])
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o input.c input.y]], [[0]],,
AT_BISON_CHECK([[-Wall -o input.c input.y]], [[0]],,
[[input.y:24.5-19: warning: rule useless in parser due to conflicts: start: start [-Wother]
input.y:28.5-19: warning: rule useless in parser due to conflicts: sr_conflict: TK2 "tok alias" [-Wother]
input.y:18.7-9: warning: useless associativity for TK1 [-Wother]
input.y:18.7-9: warning: useless precedence and associativity for TK1 [-Wprecedence]
]])
AT_COMPILE([[input]])
AT_PARSER_CHECK([[./input]])