summaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authormanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>2014-08-29 15:28:45 +0000
committermanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>2014-08-29 15:28:45 +0000
commita7d2e480fef2ab41d6a0de9ecaeb7897d401153e (patch)
treebcdc43baa9947832913a10b03e07131bc343844b /libcpp
parent49b1445b216c94da4f64025916661dccb8465047 (diff)
downloadgcc-a7d2e480fef2ab41d6a0de9ecaeb7897d401153e.tar.gz
libcpp/ChangeLog:
2014-08-29 Manuel López-Ibáñez <manu@gcc.gnu.org> * macro.c (warn_of_redefinition): Suppress warnings for builtins that lack the NODE_WARN flag, unless Wbuiltin-macro-redefined. (_cpp_create_definition): Use Wbuiltin-macro-redefined for builtins that lack the NODE_WARN flag. * directives.c (do_undef): Likewise. * init.c (cpp_init_special_builtins): Do not change flags depending on Wbuiltin-macro-redefined. gcc/c-family/ChangeLog: 2014-08-29 Manuel López-Ibáñez <manu@gcc.gnu.org> * c.opt (Wbuiltin-macro-redefined): Use CPP, Var and Init. * c-opts.c (c_common_handle_option): Do not handle here. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@214730 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog10
-rw-r--r--libcpp/directives.c5
-rw-r--r--libcpp/init.c3
-rw-r--r--libcpp/macro.c25
4 files changed, 28 insertions, 15 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index 7f88f7aa405..1516ec02c40 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,13 @@
+2014-08-29 Manuel López-Ibáñez <manu@gcc.gnu.org>
+
+ * macro.c (warn_of_redefinition): Suppress warnings for builtins
+ that lack the NODE_WARN flag, unless Wbuiltin-macro-redefined.
+ (_cpp_create_definition): Use Wbuiltin-macro-redefined for
+ builtins that lack the NODE_WARN flag.
+ * directives.c (do_undef): Likewise.
+ * init.c (cpp_init_special_builtins): Do not change flags
+ depending on Wbuiltin-macro-redefined.
+
2014-08-28 Edward Smith-Rowland <3dw4rd@verizon.net>
PR cpp/23827 - standard C++ should not have hex float preprocessor
diff --git a/libcpp/directives.c b/libcpp/directives.c
index 3486a48d21e..631557df8bb 100644
--- a/libcpp/directives.c
+++ b/libcpp/directives.c
@@ -610,6 +610,11 @@ do_undef (cpp_reader *pfile)
if (node->flags & NODE_WARN)
cpp_error (pfile, CPP_DL_WARNING,
"undefining \"%s\"", NODE_NAME (node));
+ else if ((node->flags & NODE_BUILTIN)
+ && CPP_OPTION (pfile, warn_builtin_macro_redefined))
+ cpp_warning_with_line (pfile, CPP_W_BUILTIN_MACRO_REDEFINED,
+ pfile->directive_line, 0,
+ "undefining \"%s\"", NODE_NAME (node));
if (CPP_OPTION (pfile, warn_unused_macros))
_cpp_warn_if_unused_macro (pfile, node, NULL);
diff --git a/libcpp/init.c b/libcpp/init.c
index 7aace802682..2998d880aa4 100644
--- a/libcpp/init.c
+++ b/libcpp/init.c
@@ -470,8 +470,7 @@ cpp_init_special_builtins (cpp_reader *pfile)
cpp_hashnode *hp = cpp_lookup (pfile, b->name, b->len);
hp->type = NT_MACRO;
hp->flags |= NODE_BUILTIN;
- if (b->always_warn_if_redefined
- || CPP_OPTION (pfile, warn_builtin_macro_redefined))
+ if (b->always_warn_if_redefined)
hp->flags |= NODE_WARN;
hp->value.builtin = (enum cpp_builtin_type) b->value;
}
diff --git a/libcpp/macro.c b/libcpp/macro.c
index a1ba1373615..8445ce39eda 100644
--- a/libcpp/macro.c
+++ b/libcpp/macro.c
@@ -2699,13 +2699,12 @@ warn_of_redefinition (cpp_reader *pfile, 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)
- {
- if (!pfile->cb.user_builtin_macro
- || !pfile->cb.user_builtin_macro (pfile, node))
- return false;
- }
+ /* Suppress warnings for builtins that lack the NODE_WARN flag,
+ unless Wbuiltin-macro-redefined. */
+ if (node->flags & NODE_BUILTIN
+ && (!pfile->cb.user_builtin_macro
+ || !pfile->cb.user_builtin_macro (pfile, node)))
+ return CPP_OPTION (pfile, warn_builtin_macro_redefined);
/* Redefinitions of conditional (context-sensitive) macros, on
the other hand, must be allowed silently. */
@@ -3181,14 +3180,14 @@ _cpp_create_definition (cpp_reader *pfile, cpp_hashnode *node)
if (warn_of_redefinition (pfile, node, macro))
{
- const int reason = (node->flags & NODE_BUILTIN)
+ const int reason = ((node->flags & NODE_BUILTIN)
+ && !(node->flags & NODE_WARN))
? CPP_W_BUILTIN_MACRO_REDEFINED : CPP_W_NONE;
- bool warned;
- warned = cpp_pedwarning_with_line (pfile, reason,
- pfile->directive_line, 0,
- "\"%s\" redefined",
- NODE_NAME (node));
+ bool warned =
+ cpp_pedwarning_with_line (pfile, reason,
+ pfile->directive_line, 0,
+ "\"%s\" redefined", NODE_NAME (node));
if (warned && node->type == NT_MACRO && !(node->flags & NODE_BUILTIN))
cpp_error_with_line (pfile, CPP_DL_NOTE,