diff options
author | Akim Demaille <akim.demaille@gmail.com> | 2019-09-27 18:28:19 +0200 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2019-10-06 09:54:25 +0200 |
commit | be3cf406afcd68bbf1c113607f3362722f4418d1 (patch) | |
tree | ba19fa11dedeb8ba306533fa6c4c441ebc5f2de9 /tests | |
parent | 126c4622de27197bbe4c6a713f28d114839e636f (diff) | |
download | bison-be3cf406afcd68bbf1c113607f3362722f4418d1.tar.gz |
diagnostics: suggest fixes for undeclared symbols
From
input.y:1.17-19: warning: symbol baz is used, but is not defined as a token and has no rules [-Wother]
1 | %printer {} foo baz
| ^~~
to
input.y:1.17-19: warning: symbol 'baz' is used, but is not defined as a token and has no rules; did you mean 'bar'? [-Wother]
1 | %printer {} foo baz
| ^~~
| bar
* bootstrap.conf: We need fstrcmp.
* src/symtab.c (symbol_from_uniqstr_fuzzy): New.
(complain_symbol_undeclared): Use it.
* tests/diagnostics.at (Suggestions): New.
* data/bison-default.css (insertion): Rename as...
(fixit-insert): this, as this is what GCC uses.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/diagnostics.at | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/tests/diagnostics.at b/tests/diagnostics.at index 4042a815..bd01c15d 100644 --- a/tests/diagnostics.at +++ b/tests/diagnostics.at @@ -46,7 +46,7 @@ AT_DATA([experr], [$4]) AT_CHECK([LC_ALL=en_US.UTF-8 $5 bison -fcaret --color=debug -Wall input.y], [$3], [], [experr]) # When no style, same messages, but without style. -AT_CHECK([perl -pi -e 's{(</?\w+>)}{ $[]1 eq "<tag>" ? $[]1 : "" }ge' experr]) +AT_CHECK([perl -pi -e 's{(</?(-|\w)+>)}{ $[]1 eq "<tag>" ? $[]1 : "" }ge' experr]) # Cannot use AT_BISON_CHECK easily as we need to change the # environment. @@ -344,7 +344,7 @@ input.y:9.8-33: previous declaration input.y:10.56-69: <warning>warning:</warning> deprecated directive: '%error-verbose', use '%define parse.error verbose' [<warning>-Wdeprecated</warning>] 10 | <warning>%error-verbose</warning> | <warning>^~~~~~~~~~~~~~</warning> - | <insertion>%define parse.error verbose</insertion> + | <fixit-insert>%define parse.error verbose</fixit-insert> input.y: <warning>warning:</warning> fix-its can be applied. Rerun with option '--update'. [<warning>-Wother</warning>] ]], [[COLUMNS=200]]) @@ -377,7 +377,7 @@ input.y:9.8-33: previous declaration input.y:10.56-69: <warning>warning:</warning> deprecated directive: '%error-verbose', use '%define parse.error verbose' [<warning>-Wdeprecated</warning>] 10 | <warning>%error-verbose</warning> | <warning>^~~~~~~~~~~~~~</warning> - | <insertion>%define parse.error verbose</insertion> + | <fixit-insert>%define parse.error verbose</fixit-insert> input.y: <warning>warning:</warning> fix-its can be applied. Rerun with option '--update'. [<warning>-Wother</warning>] ]], [[COLUMNS=80]]) @@ -410,11 +410,39 @@ input.y:9.8-33: previous declaration input.y:10.56-69: <warning>warning:</warning> deprecated directive: '%error-verbose', use '%define parse.error verbose' [<warning>-Wdeprecated</warning>] 10 | ... <warning>%error-verbose</warning> | <warning>^~~~~~~~~~~~~~</warning> - | <insertion>%define parse.error verbose</insertion> + | <fixit-insert>%define parse.error verbose</fixit-insert> input.y: <warning>warning:</warning> fix-its can be applied. Rerun with option '--update'. [<warning>-Wother</warning>] ]], [[COLUMNS=60]]) + +## ------------- ## +## Suggestions. ## +## ------------- ## + +# Don't suggest to fix QUX with QUUX and QUUX with QUX... +AT_TEST([[Suggestions]], +[[%% +res: QUX baz +bar: QUUX +]], +[1], +[[input.y:11.6-9: <error>error:</error> symbol 'QUUX' is used, but is not defined as a token and has no rules + 11 | bar: <error>QUUX</error> + | <error>^~~~</error> +input.y:10.6-8: <error>error:</error> symbol 'QUX' is used, but is not defined as a token and has no rules + 10 | res: <error>QUX</error> baz + | <error>^~~</error> +input.y:10.10-12: <error>error:</error> symbol 'baz' is used, but is not defined as a token and has no rules; did you mean 'bar'? + 10 | res: QUX <error>baz</error> + | <error>^~~</error> + | <fixit-insert>bar</fixit-insert> +]]) + + + + + m4_popdef([AT_TEST]) |