mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-16 07:43:03 +00:00
diagnostics: modernize the display of submessages
Since Bison 2.7, output was indented four spaces for explanatory
statements. For example:
input.y:2.7-13: error: %type redeclaration for exp
input.y:1.7-11: previous declaration
Since the introduction of caret-diagnostics, it became less clear.
Remove the indentation and display submessages as in GCC:
input.y:2.7-13: error: %type redeclaration for exp
2 | %type <float> exp
| ^~~~~~~
input.y:1.7-11: note: previous declaration
1 | %type <int> exp
| ^~~~~
* src/complain.h (SUB_INDENT): Remove.
(warnings): Add "note" to the enum.
* src/complain.h, src/complain.c (complain_indent): Replace by...
(subcomplain): this.
Adjust all dependencies.
* tests/actions.at, tests/diagnostics.at, tests/glr-regression.at,
* tests/input.at, tests/named-refs.at, tests/regression.at:
Adjust expectations.
This commit is contained in:
committed by
Akim Demaille
parent
a09d0ae4d1
commit
e09a72eeb0
46
TODO
46
TODO
@@ -95,52 +95,6 @@ and https://research.swtch.com/yyerror.
|
||||
** consistency
|
||||
token vs terminal, variable vs non terminal.
|
||||
|
||||
** Stop indentation in diagnostics
|
||||
Before Bison 2.7, we printed "flatly" the dependencies in long diagnostics:
|
||||
|
||||
input.y:2.7-12: %type redeclaration for exp
|
||||
input.y:1.7-12: previous declaration
|
||||
|
||||
In Bison 2.7, we indented them
|
||||
|
||||
input.y:2.7-12: error: %type redeclaration for exp
|
||||
input.y:1.7-12: previous declaration
|
||||
|
||||
Later we quoted the source in the diagnostics, and today we have:
|
||||
|
||||
/tmp/foo.y:1.12-14: warning: symbol FOO redeclared [-Wother]
|
||||
1 | %token FOO FOO
|
||||
| ^~~
|
||||
/tmp/foo.y:1.8-10: previous declaration
|
||||
1 | %token FOO FOO
|
||||
| ^~~
|
||||
|
||||
The indentation is no longer helping. We should probably get rid of it, or
|
||||
maybe keep it only when -fno-caret. GCC displays this as a "note":
|
||||
|
||||
$ g++-mp-9 -Wall /tmp/foo.c -c
|
||||
/tmp/foo.c:1:10: error: redefinition of 'int foo'
|
||||
1 | int foo, foo;
|
||||
| ^~~
|
||||
/tmp/foo.c:1:5: note: 'int foo' previously declared here
|
||||
1 | int foo, foo;
|
||||
| ^~~
|
||||
|
||||
Likewise for Clang, contrary to what I believed (because "note:" is written
|
||||
in black, so it doesn't show in my terminal :-)
|
||||
|
||||
$ clang++-mp-8.0 -Wall /tmp/foo.c -c
|
||||
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
|
||||
/tmp/foo.c:1:10: error: redefinition of 'foo'
|
||||
int foo, foo;
|
||||
^
|
||||
/tmp/foo.c:1:5: note: previous definition is here
|
||||
int foo, foo;
|
||||
^
|
||||
1 error generated.
|
||||
|
||||
See also the item "Complaint submessage indentation" below.
|
||||
|
||||
** api.token.raw
|
||||
Maybe we should exhibit the YYUNDEFTOK token. It could also be assigned a
|
||||
semantic value so that yyerror could be used to report invalid lexemes.
|
||||
|
||||
Reference in New Issue
Block a user