* RFA (tree.c): PATCH to make warn_deprecated_use return bool
@ 2018-05-16 2:34 Jason Merrill
2018-05-16 9:42 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Jason Merrill @ 2018-05-16 2:34 UTC (permalink / raw)
To: gcc-patches List
[-- Attachment #1: Type: text/plain, Size: 407 bytes --]
The function "warning" returns bool to indicated whether or not any
diagnostic was actually emitted; warn_deprecated_use should as well.
It's also unnecessary to duplicate the warning code between the cases
of null or non-null "decl", since the actual warnings were the same.
The only thing that's different is whether we indicate the source
location of "decl".
Tested x86_64-pc-linux-gnu. OK for trunk?
[-- Attachment #2: warn-depr-bool.diff --]
[-- Type: text/x-patch, Size: 3144 bytes --]
commit b49f292814693de97b218f6d8b32b20dd68fb8c8
Author: Jason Merrill <jason@redhat.com>
Date: Tue May 15 17:41:19 2018 -0400
* tree.c (warn_deprecated_use): Return bool. Simplify logic.
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);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: RFA (tree.c): PATCH to make warn_deprecated_use return bool
2018-05-16 2:34 RFA (tree.c): PATCH to make warn_deprecated_use return bool Jason Merrill
@ 2018-05-16 9:42 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2018-05-16 9:42 UTC (permalink / raw)
To: Jason Merrill; +Cc: GCC Patches
On Wed, May 16, 2018 at 3:01 AM Jason Merrill <jason@redhat.com> wrote:
> The function "warning" returns bool to indicated whether or not any
> diagnostic was actually emitted; warn_deprecated_use should as well.
> It's also unnecessary to duplicate the warning code between the cases
> of null or non-null "decl", since the actual warnings were the same.
> The only thing that's different is whether we indicate the source
> location of "decl".
> Tested x86_64-pc-linux-gnu. OK for trunk?
OK.
Richard.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-05-16 9:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-16 2:34 RFA (tree.c): PATCH to make warn_deprecated_use return bool Jason Merrill
2018-05-16 9:42 ` Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).