diff options
Diffstat (limited to 'gcc/cppinit.c')
-rw-r--r-- | gcc/cppinit.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/gcc/cppinit.c b/gcc/cppinit.c index 22ce18df1e3..d8efb4b559c 100644 --- a/gcc/cppinit.c +++ b/gcc/cppinit.c @@ -607,7 +607,9 @@ cpp_destroy (pfile) /* This structure defines one built-in identifier. A node will be entered in the hash table under the name NAME, with value VALUE (if any). If flags has OPERATOR, the node's operator field is used; if - flags has BUILTIN the node's builtin field is used. + flags has BUILTIN the node's builtin field is used. Macros that are + known at build time should not be flagged BUILTIN, as then they do + not appear in macro dumps with e.g. -dM or -dD. Two values are not compile time constants, so we tag them in the FLAGS field instead: @@ -632,7 +634,6 @@ struct builtin #define OPERATOR 0x10 #define B(n, t) { U n, 0, t, 0, BUILTIN, sizeof n - 1 } -#define BC(n, t) { U n, 0, t, 0, BUILTIN | CPLUS, sizeof n - 1 } #define C(n, v) { U n, v, 0, 0, 0, sizeof n - 1 } #define X(n, f) { U n, 0, 0, 0, f, sizeof n - 1 } #define O(n, c, f) { U n, 0, 0, c, OPERATOR | f, sizeof n - 1 } @@ -644,8 +645,6 @@ static const struct builtin builtin_array[] = B("__BASE_FILE__", BT_BASE_FILE), B("__LINE__", BT_SPECLINE), B("__INCLUDE_LEVEL__", BT_INCLUDE_LEVEL), - B("__STDC__", BT_STDC), - BC("__GXX_WEAK__", BT_WEAK), X("__VERSION__", VERS), X("__USER_LABEL_PREFIX__", ULP), @@ -663,6 +662,11 @@ static const struct builtin builtin_array[] = #ifndef NO_BUILTIN_WINT_TYPE C("__WINT_TYPE__", WINT_TYPE), #endif +#ifdef STDC_0_IN_SYSTEM_HEADERS + B("__STDC__", BT_STDC), +#else + C("__STDC__", "1"), +#endif /* Named operators known to the preprocessor. These cannot be #defined and always have their stated meaning. They are treated like normal @@ -714,7 +718,7 @@ init_builtins (pfile) else { hp->type = NT_MACRO; - hp->flags |= NODE_BUILTIN; + hp->flags |= NODE_BUILTIN | NODE_WARN; hp->value.builtin = b->builtin; } } @@ -746,7 +750,13 @@ init_builtins (pfile) } if (CPP_OPTION (pfile, cplusplus)) - _cpp_define_builtin (pfile, "__cplusplus 1"); + { + _cpp_define_builtin (pfile, "__cplusplus 1"); + if (SUPPORTS_ONE_ONLY) + _cpp_define_builtin (pfile, "__GXX_WEAK__ 1"); + else + _cpp_define_builtin (pfile, "__GXX_WEAK__ 0"); + } if (CPP_OPTION (pfile, objc)) _cpp_define_builtin (pfile, "__OBJC__ 1"); |