grammar: record used associativity and print useless ones

Record which symbol associativity is used, and display useless ones.

* src/symtab.h, src/symtab.c (register_assoc, print_assoc_warnings): New
* src/symtab.c (init_assoc, is_assoc_used): New
* src/main.c: Use print_assoc_warnings
* src/conflicts.c: Use register_assoc
* tests/conflicts.at (Useless associativity warning): New.

Due to the new warning, many tests had to be updated.

* tests/conflicts.at tests/existing.at tests/regression.at:
Add the associativity warning in the expected results.
* tests/java.at: Fix the java calculator's grammar to remove a useless
associativity.
* doc/bison.texi (mfcalc example): Fix associativity to remove
warning.
This commit is contained in:
Valentin Tolmer
2013-01-29 16:27:04 +01:00
committed by Akim Demaille
parent 284bc49c83
commit e8f7155d98
9 changed files with 275 additions and 9 deletions

View File

@@ -377,7 +377,10 @@ exp: ;
%%
]])
AT_BISON_CHECK([-v -o input.c input.y])
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_CLEANUP
@@ -1147,6 +1150,7 @@ AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-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]
]])
AT_COMPILE([[input]])
AT_PARSER_CHECK([[./input]])