[llvm-bugs] [Bug 31324] New: Defines from command line override defines from pch:

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Dec 8 16:07:59 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=31324

            Bug ID: 31324
           Summary: Defines from command line override defines from pch:
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nicolasweber at gmx.de
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

$ cat foo.h
#define __STDC_HOSTED__ "hi"
$ cat foo.c
const char* s = __STDC_HOSTED__;

$ bin/clang -cc1 -emit-pch -o foo.h.pch foo.h
foo.h:1:9: warning: '__STDC_HOSTED__' macro redefined
#define __STDC_HOSTED__ "hi"
        ^
<built-in>:307:9: note: previous definition is here
#define __STDC_HOSTED__ 1
        ^
1 warning generated.
$ bin/clang -cc1 -D__STDC_HOSTED__=4 -include-pch foo.h.pch -emit-obj -o foo.o
foo.c
<built-in>:1:9: warning: '__STDC_HOSTED__' macro redefined
#define __STDC_HOSTED__ 4
        ^
/Users/thakis/src/llvm-build/foo.h:1:9: note: previous definition is here
#define __STDC_HOSTED__ "hi"
        ^
foo.c:1:13: warning: incompatible integer to pointer conversion initializing
'const char *' with an expression of type 'int'
const char* s = __STDC_HOSTED__;
            ^   ~~~~~~~~~~~~~~~
2 warnings generated.


But:

$ bin/clang -cc1 -D__STDC_HOSTED__=4 -include foo.h -emit-obj -o foo.o foo.c
In file included from <built-in>:311:
<command line>:1:9: warning: '__STDC_HOSTED__' macro redefined
#define __STDC_HOSTED__ 4
        ^
<built-in>:307:9: note: previous definition is here
#define __STDC_HOSTED__ 1
        ^
In file included from <built-in>:1:
./foo.h:1:9: warning: '__STDC_HOSTED__' macro redefined
#define __STDC_HOSTED__ "hi"
        ^
<command line>:1:9: note: previous definition is here
#define __STDC_HOSTED__ 4
        ^
2 warnings generated.


(Noticed by Richard Smith in https://reviews.llvm.org/D27545)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20161209/0d3a40ce/attachment-0001.html>


More information about the llvm-bugs mailing list