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: unassig...@gcc.gnu.org

        ReportedBy: r...@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;"

Reply via email to