https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119080
Bug ID: 119080
Summary: Poor error message when parameter type is unknown
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: higher.performance.github at gmail dot com
Target Milestone: ---
If you have a declaration such as
void foo(intptr_t);
the first error message produced ends up being quite confusing:
https://godbolt.org/z/414c6zE8q
<source>:1:6: error: variable or field 'foo' declared void
1 | void foo(intptr_t);
| ^~~
The subsequent error messages end up clarifying the situation:
<source>:1:10: error: 'intptr_t' was not declared in this scope
1 | void foo(intptr_t);
| ^~~~~~~~
<source>:1:1: note: 'intptr_t' is defined in header '<cstdint>'; this is
probably fixable by adding '#include <cstdint>'
+++ |+#include <cstdint>
1 | void foo(intptr_t);
but they aren't always immediately visible to users, and users don't
necessarily expect subsequent errors to pinpoint problems in previous error
messages.
Given that the error already first occurs at the parameter and *then* on the
function, emitting the errors in the opposite order would be super helpful.