[Bug c++/102774] Stop showing "error: variable or field ‘f’ declared void" after an earlier error in a declarator
barry.revzin at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed May 18 22:52:11 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102774
Barry Revzin <barry.revzin at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |barry.revzin at gmail dot com
--- Comment #1 from Barry Revzin <barry.revzin at gmail dot com> ---
Was just filing a bug for the same problem. Here's a short repro:
namespace A::B {
struct X { void use(); };
}
void f(B::X x, int j) {
x.use();
}
The error I get is:
<source>:5:6: error: variable or field 'f' declared void
5 | void f(B::X x, int j) {
| ^
<source>:5:8: error: 'B' has not been declared
5 | void f(B::X x, int j) {
| ^
<source>:5:16: error: expected primary-expression before 'int'
5 | void f(B::X x, int j) {
| ^~~
The middle error is the real problem, the first and third are... quite
unhelpful! In some cases, the third error looks more like this:
<source>:7:18: error: expected primary-expression before 'j'
7 | void f(B::X x, Y j) {
| ^
Which is equivalently unhelpful.
More information about the Gcc-bugs
mailing list