This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/16151] New: Poor diagnostics
- From: "igodard at pacbell dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Jun 2004 05:38:46 -0000
- Subject: [Bug c++/16151] New: Poor diagnostics
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
class B{};
class A{
public:
void Foo(b& buf) {}
};
void Bar(b& fub){}
int main() {
return 0;
}
Gets you:
~/ootbc/common/test/src$ g++ foo.cc
foo.cc:4: error: variable or field `Foo' declared void
foo.cc:4: error: expected `;' before '(' token
foo.cc:5: error: expected `;' before '}' token
foo.cc:7: error: variable or field `Bar' declared void
foo.cc:7: error: `b' was not declared in this scope
foo.cc:7: error: `fub' was not declared in this scope
foo.cc:7: error: expected `,' or `;' before '{' token
The actual problem is that both "b" should have been "B", so there should be at most two "undefined identifier" messages - only one if (as gcc usually does) the second and subsequent are suppressed. Instead we get only one 'b' error, but on the *second* occurrance; three spurious errors wanting ";"; two very odd "declared void" messages; and one unknown identifier on "fub" that is not matched by one on "buf". It is not clear to me why the two cases (class vs. file scope) do not produce identical messages, but there you are.
Comeau gives:
"ComeauTest.c", line 4: error: identifier "b" is undefined
void Foo(b& buf) {}
^
"ComeauTest.c", line 7: error: incomplete type is not allowed
void Bar(b& fub){}
^
"ComeauTest.c", line 7: error: identifier "b" is undefined
void Bar(b& fub){}
^
"ComeauTest.c", line 7: error: identifier "fub" is undefined
void Bar(b& fub){}
^
"ComeauTest.c", line 7: error: expected a ";" (perhaps on the previous statement)
void Bar(b& fub){}
^
At end of source: warning: parsing restarts here after previous syntax error
This is somewhat but not that much better: they get both instances of 'b', only one ";", and no "void" nessages. But like gcc they also give "fub" but not "buf", and they add an "incomplete type" message - but only on the error in class scope.
--
Summary: Poor diagnostics
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: igodard at pacbell dot net
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16151