From 618cdda7f07c46b4e6e76ed1c0947cc9bf6a77f1 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Sun, 25 Feb 2001 09:43:03 +0000 Subject: cppinit.c (builtin_array): Update. * cppinit.c (builtin_array): Update. (init_builtins): Flag builtins to warn if redefined or undefined. Define __GXX_WEAK as a normal macro. * cpplib.c (do_undef): Warn if flagged NODE_WARN. * cpplib.h (NODE_WARN): New flag. * cppmacro.c (builtin_macro): Remove handling of __GXX_WEAK__. Handle __STDC__ as a builtin only on Solaris. (warn_of_redefinition): Renamed from check_macro_definition. Reverse sense of test. Always warn if NODE_WARN. (_cpp_create_definition): Use warn_of_redefinition. Flag any macro beginning with "__STDC_" to require a mandatory warning if redefined or undefined. From-SVN: r40053 --- gcc/cppinit.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'gcc/cppinit.c') diff --git a/gcc/cppinit.c b/gcc/cppinit.c index 22ce18d..d8efb4b 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"); -- cgit v1.1