[Bug c++/102774] Stop showing "error: variable or field ‘f’ declared void" after an earlier error in a declarator
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102774 Jonathan Wakely changed: What|Removed |Added Last reconfirmed|2022-05-18 00:00:00 |2024-5-21 --- Comment #5 from Jonathan Wakely --- Another one: template void func(T) { } f.cc:1:48: error: variable or field ‘func’ declared void 1 | template void func(T) { } |^~~~ f.cc:1:53: error: ‘T’ was not declared in this scope 1 | template void func(T) { } | ^
[Bug c++/102774] Stop showing "error: variable or field ‘f’ declared void" after an earlier error in a declarator
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102774 Barry Revzin changed: What|Removed |Added CC||barry.revzin at gmail dot com --- Comment #1 from Barry Revzin --- 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: :5:6: error: variable or field 'f' declared void 5 | void f(B::X x, int j) { | ^ :5:8: error: 'B' has not been declared 5 | void f(B::X x, int j) { |^ :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: :7:18: error: expected primary-expression before 'j' 7 | void f(B::X x, Y j) { | ^ Which is equivalently unhelpful.
[Bug c++/102774] Stop showing "error: variable or field ‘f’ declared void" after an earlier error in a declarator
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102774 Marek Polacek changed: What|Removed |Added CC||mpolacek at gcc dot gnu.org Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Last reconfirmed||2022-05-18 --- Comment #2 from Marek Polacek --- Confirmed.
[Bug c++/102774] Stop showing "error: variable or field ‘f’ declared void" after an earlier error in a declarator
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102774 --- Comment #3 from Jonathan Wakely --- For the first case: template void f(T...) { } GCC prints: f.C:1:18: error: expected nested-name-specifier before ‘.’ token 1 | template void f(T...) { } | ^ f.C:1:18: error: expected ‘>’ before ‘.’ token f.C:1:29: error: variable or field ‘f’ declared void 1 | template void f(T...) { } | ^ f.C:1:31: error: ‘T’ was not declared in this scope 1 | template void f(T...) { } | Clang says: f.C:1:18: error: expected a qualified name after 'typename' template void f(T...) { } ^ f.C:1:18: error: expected ',' or '>' in template-parameter-list f.C:1:31: error: unknown type name 'T' template void f(T...) { } ^ 3 errors generated. This has no "declared void" noise.
[Bug c++/102774] Stop showing "error: variable or field ‘f’ declared void" after an earlier error in a declarator
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102774 --- Comment #4 from Jonathan Wakely --- For Barry's example clang prints: g.C:5:8: error: use of undeclared identifier 'B'; did you mean 'A::B'? void f(B::X x, int j) { ^ A::B g.C:1:14: note: 'A::B' declared here namespace A::B { ^ 1 error generated. This is much better. Ideal even.