public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] tree: Fix up warn_deprecated_use [PR104627]
@ 2022-03-01 18:33 Jakub Jelinek
  2022-03-02 19:03 ` Jeff Law
  2022-03-03 21:06 ` Jason Merrill
  0 siblings, 2 replies; 3+ messages in thread
From: Jakub Jelinek @ 2022-03-01 18:33 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches

Hi!

The r12-7287-g1b71bc7c8b18bd1b change improved the -Wdeprecated
warning for C++, but regressed it for C, in particular in
gcc.dg/deprecated.c testcase we now report a type that actually isn't
deprecated as deprecated instead of the one that is deprecated.

The following change tries to find the middle ground between what
we used to do before and what r12-7287 change does.
If TYPE_STUB_DECL (node) is non-NULL (that is what happens with
those C tests), then it will do what it used to do before (just smarter,
there is no need to lookup_attribute when it is called again a few lines
below this), if it is NULL, it will try
TYPE_STUB_DECL (TYPE_MAIN_VARIANT (node)) - what the deprecated-16.C
test needs.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2022-03-01  Jakub Jelinek  <jakub@redhat.com>

	PR c/104627
	* tree.cc (warn_deprecated_use): For types prefer to use node
	and only use TYPE_MAIN_VARIANT (node) if TYPE_STUB_DECL (node) is
	NULL.

--- gcc/tree.cc.jj	2022-02-18 12:38:06.172391744 +0100
+++ gcc/tree.cc	2022-02-28 13:17:57.223216010 +0100
@@ -12047,8 +12047,11 @@ warn_deprecated_use (tree node, tree att
 	attr = DECL_ATTRIBUTES (node);
       else if (TYPE_P (node))
 	{
-	  tree decl = TYPE_STUB_DECL (TYPE_MAIN_VARIANT (node));
+	  tree decl = TYPE_STUB_DECL (node);
 	  if (decl)
+	    attr = TYPE_ATTRIBUTES (TREE_TYPE (decl));
+	  else if ((decl = TYPE_STUB_DECL (TYPE_MAIN_VARIANT (node)))
+		   != NULL_TREE)
 	    {
 	      node = TREE_TYPE (decl);
 	      attr = TYPE_ATTRIBUTES (node);

	Jakub


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] tree: Fix up warn_deprecated_use [PR104627]
  2022-03-01 18:33 [PATCH] tree: Fix up warn_deprecated_use [PR104627] Jakub Jelinek
@ 2022-03-02 19:03 ` Jeff Law
  2022-03-03 21:06 ` Jason Merrill
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff Law @ 2022-03-02 19:03 UTC (permalink / raw)
  To: Jakub Jelinek, Jason Merrill; +Cc: gcc-patches



On 3/1/2022 11:33 AM, Jakub Jelinek via Gcc-patches wrote:
> Hi!
>
> The r12-7287-g1b71bc7c8b18bd1b change improved the -Wdeprecated
> warning for C++, but regressed it for C, in particular in
> gcc.dg/deprecated.c testcase we now report a type that actually isn't
> deprecated as deprecated instead of the one that is deprecated.
>
> The following change tries to find the middle ground between what
> we used to do before and what r12-7287 change does.
> If TYPE_STUB_DECL (node) is non-NULL (that is what happens with
> those C tests), then it will do what it used to do before (just smarter,
> there is no need to lookup_attribute when it is called again a few lines
> below this), if it is NULL, it will try
> TYPE_STUB_DECL (TYPE_MAIN_VARIANT (node)) - what the deprecated-16.C
> test needs.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2022-03-01  Jakub Jelinek  <jakub@redhat.com>
>
> 	PR c/104627
> 	* tree.cc (warn_deprecated_use): For types prefer to use node
> 	and only use TYPE_MAIN_VARIANT (node) if TYPE_STUB_DECL (node) is
> 	NULL.
OK if Jason doesn't object in the next 48hrs.  While I don't think he 
will, it's possible he's aware cases where TYPE_STUB_DECL (node) might 
be non-null, but where we need to be looking up the TYPE_MAIN_VARIANT.

Jeff


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] tree: Fix up warn_deprecated_use [PR104627]
  2022-03-01 18:33 [PATCH] tree: Fix up warn_deprecated_use [PR104627] Jakub Jelinek
  2022-03-02 19:03 ` Jeff Law
@ 2022-03-03 21:06 ` Jason Merrill
  1 sibling, 0 replies; 3+ messages in thread
From: Jason Merrill @ 2022-03-03 21:06 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

On 3/1/22 14:33, Jakub Jelinek wrote:
> Hi!
> 
> The r12-7287-g1b71bc7c8b18bd1b change improved the -Wdeprecated
> warning for C++, but regressed it for C, in particular in
> gcc.dg/deprecated.c testcase we now report a type that actually isn't
> deprecated as deprecated instead of the one that is deprecated.
> 
> The following change tries to find the middle ground between what
> we used to do before and what r12-7287 change does.
> If TYPE_STUB_DECL (node) is non-NULL (that is what happens with
> those C tests), then it will do what it used to do before (just smarter,
> there is no need to lookup_attribute when it is called again a few lines
> below this), if it is NULL, it will try
> TYPE_STUB_DECL (TYPE_MAIN_VARIANT (node)) - what the deprecated-16.C
> test needs.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK, thanks.

> 2022-03-01  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR c/104627
> 	* tree.cc (warn_deprecated_use): For types prefer to use node
> 	and only use TYPE_MAIN_VARIANT (node) if TYPE_STUB_DECL (node) is
> 	NULL.
> 
> --- gcc/tree.cc.jj	2022-02-18 12:38:06.172391744 +0100
> +++ gcc/tree.cc	2022-02-28 13:17:57.223216010 +0100
> @@ -12047,8 +12047,11 @@ warn_deprecated_use (tree node, tree att
>   	attr = DECL_ATTRIBUTES (node);
>         else if (TYPE_P (node))
>   	{
> -	  tree decl = TYPE_STUB_DECL (TYPE_MAIN_VARIANT (node));
> +	  tree decl = TYPE_STUB_DECL (node);
>   	  if (decl)
> +	    attr = TYPE_ATTRIBUTES (TREE_TYPE (decl));
> +	  else if ((decl = TYPE_STUB_DECL (TYPE_MAIN_VARIANT (node)))
> +		   != NULL_TREE)
>   	    {
>   	      node = TREE_TYPE (decl);
>   	      attr = TYPE_ATTRIBUTES (node);
> 
> 	Jakub
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-03-03 21:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-01 18:33 [PATCH] tree: Fix up warn_deprecated_use [PR104627] Jakub Jelinek
2022-03-02 19:03 ` Jeff Law
2022-03-03 21:06 ` Jason Merrill

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).