https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88036
Bug ID: 88036
Summary: bogus "was not declared in this scope; did you mean
...?" fix-it when the declaration was ill-formed
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: enhancement
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
CC: dmalcolm at gcc dot gnu.org
Target Milestone: ---
void* f()
{
undeclared_type fool;
__attribute__((unused)) int food = 0;
return &fool;
}
This produces:
dym.cc: In function 'void* f()':
dym.cc:3:3: error: 'undeclared_type' was not declared in this scope
3 | undeclared_type fool;
| ^~~~~~~~~~~~~~~
dym.cc:6:11: error: 'fool' was not declared in this scope; did you mean 'food'?
6 | return &fool;
| ^~~~
| food
Obviously the first error is correct, but the second one is unhelpful. It *was*
declared, but the declaration produced an error.
That second error would be ignorable if it didn't add the "did you mean ...?"
prompt and show a fix-it that comprises 50% of the output. No, I didn't mean
"food", and I don't want to fix it.
Could we maybe keep a list of erroneous declarations, and ignore uses of them
later? Or at least suppress the fix-it?