* tree.c (warn_deprecated_use): Return bool. Simplify logic.
authorJason Merrill <jason@redhat.com>
Wed, 16 May 2018 13:19:56 +0000 (09:19 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 16 May 2018 13:19:56 +0000 (09:19 -0400)
From-SVN: r260290

gcc/ChangeLog
gcc/tree.c
gcc/tree.h

index 7043c34428a7a2f10e00f10e3376dc50e1018fd5..b90e1da89dcc9bcad25aa3853f9eab606aee2aeb 100644 (file)
@@ -1,3 +1,7 @@
+2018-05-16  Jason Merrill  <jason@redhat.com>
+
+       * tree.c (warn_deprecated_use): Return bool.  Simplify logic.
+
 2018-05-16  Richard Biener  <rguenther@suse.de>
 
        * tree-vectorizer.h (struct stmt_info_for_cost): Add where member.
index 77a73b4495e2ddde469c0d95f234348a19830ce1..68165f4deed50bd72cddf477c1000369c16fcb9a 100644 (file)
@@ -12420,14 +12420,16 @@ typedef_variant_p (const_tree type)
   return is_typedef_decl (TYPE_NAME (type));
 }
 
-/* Warn about a use of an identifier which was marked deprecated.  */
-void
+/* Warn about a use of an identifier which was marked deprecated.  Returns
+   whether a warning was given.  */
+
+bool
 warn_deprecated_use (tree node, tree attr)
 {
   const char *msg;
 
   if (node == 0 || !warn_deprecated_decl)
-    return;
+    return false;
 
   if (!attr)
     {
@@ -12450,7 +12452,7 @@ warn_deprecated_use (tree node, tree attr)
   else
     msg = NULL;
 
-  bool w;
+  bool w = false;
   if (DECL_P (node))
     {
       if (msg)
@@ -12476,49 +12478,29 @@ warn_deprecated_use (tree node, tree attr)
            what = DECL_NAME (TYPE_NAME (node));
        }
 
-      if (decl)
+      if (what)
        {
-         if (what)
-           {
-             if (msg)
-               w = warning (OPT_Wdeprecated_declarations,
-                            "%qE is deprecated: %s", what, msg);
-             else
-               w = warning (OPT_Wdeprecated_declarations,
-                            "%qE is deprecated", what);
-           }
+         if (msg)
+           w = warning (OPT_Wdeprecated_declarations,
+                        "%qE is deprecated: %s", what, msg);
          else
-           {
-             if (msg)
-               w = warning (OPT_Wdeprecated_declarations,
-                            "type is deprecated: %s", msg);
-             else
-               w = warning (OPT_Wdeprecated_declarations,
-                            "type is deprecated");
-           }
-         if (w)
-           inform (DECL_SOURCE_LOCATION (decl), "declared here");
+           w = warning (OPT_Wdeprecated_declarations,
+                        "%qE is deprecated", what);
        }
       else
        {
-         if (what)
-           {
-             if (msg)
-               warning (OPT_Wdeprecated_declarations, "%qE is deprecated: %s",
-                        what, msg);
-             else
-               warning (OPT_Wdeprecated_declarations, "%qE is deprecated", what);
-           }
+         if (msg)
+           w = warning (OPT_Wdeprecated_declarations,
+                        "type is deprecated: %s", msg);
          else
-           {
-             if (msg)
-               warning (OPT_Wdeprecated_declarations, "type is deprecated: %s",
-                        msg);
-             else
-               warning (OPT_Wdeprecated_declarations, "type is deprecated");
-           }
+           w = warning (OPT_Wdeprecated_declarations,
+                        "type is deprecated");
        }
+      if (w && decl)
+       inform (DECL_SOURCE_LOCATION (decl), "declared here");
     }
+
+  return w;
 }
 
 /* Return true if REF has a COMPONENT_REF with a bit-field field declaration
index 74a0d1881a6e598489da8afab8c5e32759db0610..ef8bff405fe738fe0350808f3b31065b82cc0aba 100644 (file)
@@ -4828,7 +4828,7 @@ extern tree tree_strip_sign_nop_conversions (tree);
 extern const_tree strip_invariant_refs (const_tree);
 extern tree lhd_gcc_personality (void);
 extern void assign_assembler_name_if_needed (tree);
-extern void warn_deprecated_use (tree, tree);
+extern bool warn_deprecated_use (tree, tree);
 extern void cache_integer_cst (tree);
 extern const char *combined_fn_name (combined_fn);