summaryrefslogtreecommitdiff
path: root/libcpp/macro.c
diff options
context:
space:
mode:
authorSimon Baldwin <simonb@google.com>2008-09-18 15:39:08 +0000
committerSimon Baldwin <simonb@gcc.gnu.org>2008-09-18 15:39:08 +0000
commitc047ce93830ab288948c3e225fc8c5efdfbe3c2a (patch)
treee6725c527874d936bd2e164a6a7f885ebaffaf47 /libcpp/macro.c
parent1d295886287812ee7e5b5bfc63ff598a2a9e9958 (diff)
cpplib.h (struct cpp_options): Add new boolean flag warn_builtin_macro_redefined.
* include/cpplib.h (struct cpp_options): Add new boolean flag warn_builtin_macro_redefined. * init.c (cpp_create_reader): Initialize warn_builtin_macro_redefined. * (struct builtin_operator): Split out from previous struct builtin, enhance extra const correctness. * (struct builtin_macro): Split out from previous struct builtin, add new always_warn_if_redefined flag, enhance const correctness. * (mark_named_operators): Use struct builtin_operator. * (cpp_init_special_builtins): Use struct builtin_macro, add NODE_WARN to builtins selectively. * macro.c (warn_of_redefinition): Return false if a builtin macro is not flagged with NODE_WARN. * c-opts.c (c_common_handle_option): Add handling for -Wbuiltin-macro-redefined command line option. * c.opt: Added builtin-macro-redefined option. * doc/invoke.texi (Warning Options): Add -Wbuiltin-macro-redefined documentation. * gcc.dg/builtin-redefine.c: New. From-SVN: r140461
Diffstat (limited to 'libcpp/macro.c')
-rw-r--r--libcpp/macro.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libcpp/macro.c b/libcpp/macro.c
index 9a470ef460b..8122648ea39 100644
--- a/libcpp/macro.c
+++ b/libcpp/macro.c
@@ -1392,6 +1392,10 @@ warn_of_redefinition (cpp_reader *pfile, const cpp_hashnode *node,
if (node->flags & NODE_WARN)
return true;
+ /* Suppress warnings for builtins that lack the NODE_WARN flag. */
+ if (node->flags & NODE_BUILTIN)
+ return false;
+
/* Redefinitions of conditional (context-sensitive) macros, on
the other hand, must be allowed silently. */
if (node->flags & NODE_CONDITIONAL)