https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84888
Bug ID: 84888
Summary: C/C++: Improve wording of unclosed paren/brace
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c
Assignee: dmalcolm at gcc dot gnu.org
Reporter: dmalcolm at gcc dot gnu.org
Target Milestone: ---
As noted by oridb on reddit:
> I also find the large, visually complex error messages confusing to
> read. For example, this makes me skim and see 3 separate errors:
>
> t.c: In function ‘log_when_out_of_range’:
> t.c:12:50: error: expected ‘)’ before ‘{’ token
> && (temperature < MIN || temperature > MAX) {
> ^~
> )
> unclosed.c:11:6: note: to match this ‘(’
> if (logging_enabled && check_range ()
> ^
> I'd rather see something like this (although, I admit the phrasing could use
> work):
>
> t.c:12:50: error: expected ')' for unclosed '(' on t.c:11:6
> && (temperature < MIN || temperature > MAX) {
> ^~
> )
I much prefer oridb's proposed wording to what we have now (in gcc 8), though
I'd prefer to keep the note; I'll open another bug with some ideas I have about
making multiple diagnostics easier on the eye.
Maybe (brainstorming here):
If it's on the same line:
t.c:12:50: error: expected ')' for unclosed '(' on column 6
If it's in the same file:
t.c:12:50: error: expected ')' for unclosed '(' at line 11 column 6
If it's in a different file:
t.c:12:50: error: expected ')' for unclosed '(' at other.c:11:6
(Or maybe it's better to always give the same format, to make it easier for
IDEs to parse?)