]> gcc.gnu.org Git - gcc.git/commitdiff
macro.c (warn_of_redefinition): Suppress warnings for builtins that lack the NODE_WAR...
authorManuel López-Ibáñez <manu@gcc.gnu.org>
Fri, 29 Aug 2014 15:28:45 +0000 (15:28 +0000)
committerManuel López-Ibáñez <manu@gcc.gnu.org>
Fri, 29 Aug 2014 15:28:45 +0000 (15:28 +0000)
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.

From-SVN: r214730

gcc/c-family/ChangeLog
gcc/c-family/c-opts.c
gcc/c-family/c.opt
libcpp/ChangeLog
libcpp/directives.c
libcpp/init.c
libcpp/macro.c

index fa11d68db3909e6d71cd99d84c338cd29c41300c..400ea34becc87e179dd68c714c4c761cb1911bf9 100644 (file)
@@ -1,3 +1,8 @@
+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.
+
 2014-08-25  Jason Merrill  <jason@redhat.com>
 
        * c.opt: Change -std=c++1y and -std=gnu++1y to be aliases for
index 1b01b4fcaef26520cfd0dd6e1172de03514e2317..81b7c96bd18098b98ef8b763e1d0fe6000d5dbc0 100644 (file)
@@ -385,10 +385,6 @@ c_common_handle_option (size_t scode, const char *arg, int value,
       cpp_opts->warn_num_sign_change = value;
       break;
 
-    case OPT_Wbuiltin_macro_redefined:
-      cpp_opts->warn_builtin_macro_redefined = value;
-      break;
-
     case OPT_Wc___compat:
       cpp_opts->warn_cxx_operator_names = value;
       break;
index d619250fc06ce3cc65790e3e61bc3dce4fc9e6d5..3a187087e7c4eac7c409f5a8dc8210a8dbbd979d 100644 (file)
@@ -292,7 +292,7 @@ C ObjC C++ ObjC++ Var(warn_bool_compare) Warning LangEnabledBy(C ObjC C++ ObjC++
 Warn about boolean expression compared with an integer value different from true/false
 
 Wbuiltin-macro-redefined
-C ObjC C++ ObjC++ Warning
+C ObjC C++ ObjC++ CPP(warn_builtin_macro_redefined) Var(cpp_warn_builtin_macro_redefined) Init(1) Warning
 Warn when a built-in preprocessor macro is undefined or redefined
 
 Wc90-c99-compat
index 7f88f7aa4057d23a00658592a7529c79369fce60..1516ec02c4057f68a5d6eb2f4d2dd0c241ff8b74 100644 (file)
@@ -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
index 3486a48d21e9743935258c65a439edc922fef4dd..631557df8bb5eec62ef2b28b19c06f286676de1d 100644 (file)
@@ -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);
index 7aace802682187da5065832850c28ba8b5d112ce..2998d880aa4511e7f152341cad1799fe5782a57a 100644 (file)
@@ -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;
     }
index a1ba1373615f540cae8ac1467db84f93b36adf66..8445ce39eda7f50b7faaa584355e98412f83841f 100644 (file)
@@ -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,
This page took 0.087346 seconds and 5 git commands to generate.