From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6156 invoked by alias); 9 Nov 2012 18:07:33 -0000 Received: (qmail 5726 invoked by uid 48); 9 Nov 2012 18:07:06 -0000 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/55252] New: Caret diagnostic doesn't show useful location when macro clashes with name in system header Date: Fri, 09 Nov 2012 18:07:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 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: 2012-11/txt/msg00840.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55252 Bug #: 55252 Summary: Caret diagnostic doesn't show useful location when macro clashes with name in system header Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: redi@gcc.gnu.org (preprocessed source doesn't show the error due to the system_header pragma) $ cat test.cc #define bar 1 #include "header.h" $ cat header.h #pragma GCC system_header int bar = 0; $ g++ test.cc test.cc:1:13: error: expected unqualified-id before numeric constant #define bar 1 ^ This is no help because it doesn't point you to the line in header.h that clashes with 'bar' Without the system_header pragma you get test.cc:1:13: error: expected unqualified-id before numeric constant #define bar 1 ^ header.h:2:5: note: in expansion of macro 'bar' int bar = 0; ^ Which at least shows both locations, although the first diagnostic is still confusing ... are the two locations backwards? The "expected unqualified-id before numeric constant" should point to "int bar = 0;"