public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/16151] New: Poor diagnostics
@ 2004-06-23  5:54 igodard at pacbell dot net
  2004-06-23  6:10 ` [Bug c++/16151] " pinskia at gcc dot gnu dot org
  2004-07-22 12:58 ` bangerth at dealii dot org
  0 siblings, 2 replies; 7+ messages in thread
From: igodard at pacbell dot net @ 2004-06-23  5:54 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 7+ messages in thread
[parent not found: <bug-16151-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2023-05-03 15:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-23  5:54 [Bug c++/16151] New: Poor diagnostics igodard at pacbell dot net
2004-06-23  6:10 ` [Bug c++/16151] " pinskia at gcc dot gnu dot org
2004-07-22 12:58 ` bangerth at dealii dot org
     [not found] <bug-16151-4@http.gcc.gnu.org/bugzilla/>
2023-03-02 23:42 ` cvs-commit at gcc dot gnu.org
2023-03-19  5:30 ` cvs-commit at gcc dot gnu.org
2023-05-02 20:15 ` cvs-commit at gcc dot gnu.org
2023-05-03 15:22 ` cvs-commit at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).