From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25212 invoked by alias); 23 Apr 2009 00:41:31 -0000 Received: (qmail 25176 invoked by uid 48); 23 Apr 2009 00:41:18 -0000 Date: Thu, 23 Apr 2009 00:41:00 -0000 Subject: [Bug c++/39859] New: C++: Duplicated and unhelpful error for "c:n" X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "ian at airs dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2009-04/txt/msg02088.txt.bz2 When I compile this erroneous C++ program namespace n { const int c = 1; } int foo() { return n:c; } I get this: foo.cc: In function ‘int foo()’: foo.cc:2: error: expected primary-expression before ‘:’ token foo.cc:2: error: expected ‘;’ before ‘:’ token foo.cc:2: error: expected primary-expression before ‘:’ token foo.cc:2: error: expected ‘;’ before ‘:’ token The duplicated error messages are useless; I think that is a bug. Even if that bug is fixed, this error message could be better. The error is using a single colon instead of two colons. "expected primary-expression" is not helpful to the user. Firstly, as in PR 39858, what is missing is an expression, not a primary-expression. Secondly, the colon is clearly out of place; if we found an expression, we would still fail. In this case, we actually know that we just saw a NAMESPACE_DECL. We can give a better error message in this context. -- Summary: C++: Duplicated and unhelpful error for "c:n" Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: trivial Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ian at airs dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39859