diff options
author | Akim Demaille <akim.demaille@gmail.com> | 2019-10-02 08:57:58 +0200 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2019-10-06 09:54:25 +0200 |
commit | fec13ce2db675d18afb887e3c98f347a2b3de31e (patch) | |
tree | 66b93edf35ec629e4a5698704d5deb9c4c306706 /tests | |
parent | be3cf406afcd68bbf1c113607f3362722f4418d1 (diff) | |
download | bison-fec13ce2db675d18afb887e3c98f347a2b3de31e.tar.gz |
diagnostics: sort symbols per location
Because the checking of the grammar is made by phases after the whole
grammar was read, we sometimes have diagnostics that look weird. In
some case, within one type of checking, the entities are not checked
in the order in which they appear in the file. For instance, checking
symbols is done on the list of symbols sorted by tag:
foo.y:1.20-22: warning: symbol BAR is used, but is not defined as a token and has no rules [-Wother]
1 | %destructor {} QUX BAR
| ^~~
foo.y:1.16-18: warning: symbol QUX is used, but is not defined as a token and has no rules [-Wother]
1 | %destructor {} QUX BAR
| ^~~
Let's sort them by location instead:
foo.y:1.16-18: warning: symbol 'QUX' is used, but is not defined as a token and has no rules [-Wother]
1 | %destructor {} QUX BAR
| ^~~
foo.y:1.20-22: warning: symbol 'BAR' is used, but is not defined as a token and has no rules [-Wother]
1 | %destructor {} QUX BAR
| ^~~
* src/location.h (location_cmp): Be robust to empty file names.
* src/symtab.c (symbol_cmp): Sort by location.
* tests/input.at: Adjust expectations.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/diagnostics.at | 8 | ||||
-rw-r--r-- | tests/input.at | 16 |
2 files changed, 12 insertions, 12 deletions
diff --git a/tests/diagnostics.at b/tests/diagnostics.at index bd01c15d..deac06ff 100644 --- a/tests/diagnostics.at +++ b/tests/diagnostics.at @@ -427,16 +427,16 @@ 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 +[[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> +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> ]]) diff --git a/tests/input.at b/tests/input.at index e5d7666b..976e5395 100644 --- a/tests/input.at +++ b/tests/input.at @@ -822,15 +822,15 @@ exp: bar; ]]) 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 - 2 | %destructor {} bar - | ^~~ +[[input.y:1.13-15: warning: symbol 'foo' is used, but is not defined as a token and has no rules [-Wother] + 1 | %printer {} foo baz + | ^~~ 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 | ^~~ -input.y:1.13-15: warning: symbol 'foo' is used, but is not defined as a token and has no rules [-Wother] - 1 | %printer {} foo baz - | ^~~ +input.y:2.16-18: error: symbol 'bar' is used, but is not defined as a token and has no rules + 2 | %destructor {} bar + | ^~~ input.y:3.13-15: warning: symbol 'qux' is used, but is not defined as a token and has no rules [-Wother] 3 | %type <foo> qux | ^~~ @@ -1061,9 +1061,9 @@ AT_BISON_CHECK([-fcaret input.y], [1], [], input.y:2.10-12: error: user token number 42 redeclaration for BAR 2 | BAR 42 "foo" | ^~~ -input.y:1.8-10: previous declaration for FOO +input.y:1.15-19: previous declaration for "foo" 1 | %token FOO 42 "foo" - | ^~~ + | ^~~~~ ]]) AT_CLEANUP |