From df0fc585b70b65a188de010f50cb90b0db3b9045 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 16 May 2018 09:19:56 -0400 Subject: [PATCH] * tree.c (warn_deprecated_use): Return bool. Simplify logic. From-SVN: r260290 --- gcc/ChangeLog | 4 ++++ gcc/tree.c | 60 ++++++++++++++++++--------------------------------- gcc/tree.h | 2 +- 3 files changed, 26 insertions(+), 40 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7043c34428a..b90e1da89dc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2018-05-16 Jason Merrill + + * tree.c (warn_deprecated_use): Return bool. Simplify logic. + 2018-05-16 Richard Biener * tree-vectorizer.h (struct stmt_info_for_cost): Add where member. diff --git a/gcc/tree.c b/gcc/tree.c index 77a73b4495e..68165f4deed 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -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 diff --git a/gcc/tree.h b/gcc/tree.h index 74a0d1881a6..ef8bff405fe 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -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); -- 2.30.2