warn-access: Fix up warning_at arguments

Message ID 20220121070441.GB2646553@tucnak
State New
Headers
Series warn-access: Fix up warning_at arguments |

Commit Message

Jakub Jelinek Jan. 21, 2022, 7:04 a.m. UTC
  Hi!

A warning regression fix I'm about to post warns (and breaks bootstrap due
to that) on the following spot.  Seems it is a copy and paste from
earlier code that mentions the %qD variable instead of talking about
unnamed temporary.

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

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

	* gimple-ssa-warn-access.cc (pass_waccess::warn_invalid_pointer):
	Avoid passing var to warning_at when the format string doesn't
	refer to it.


	Jakub
  

Comments

Richard Biener Jan. 21, 2022, 7:18 a.m. UTC | #1
On Fri, 21 Jan 2022, Jakub Jelinek wrote:

> Hi!
> 
> A warning regression fix I'm about to post warns (and breaks bootstrap due
> to that) on the following spot.  Seems it is a copy and paste from
> earlier code that mentions the %qD variable instead of talking about
> unnamed temporary.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK.

Richrd.

> 2022-01-21  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* gimple-ssa-warn-access.cc (pass_waccess::warn_invalid_pointer):
> 	Avoid passing var to warning_at when the format string doesn't
> 	refer to it.
> 
> --- gcc/gimple-ssa-warn-access.cc.jj	2022-01-20 21:24:40.600955673 +0100
> +++ gcc/gimple-ssa-warn-access.cc	2022-01-20 22:58:19.488226389 +0100
> @@ -3953,15 +3953,14 @@ pass_waccess::warn_invalid_pointer (tree
>  			    "may be used")
>  		       : G_("using dangling pointer %qE to an unnamed "
>  			    "temporary")),
> -		      ref, var))
> +		      ref))
>        || (!ref
>  	  && warning_at (use_loc, OPT_Wdangling_pointer_,
>  			 (maybe
>  			  ? G_("dangling pointer to an unnamed temporary "
>  			       "may be used")
>  			  : G_("using a dangling pointer to an unnamed "
> -			       "temporary")),
> -			 var)))
> +			       "temporary")))))
>      {
>        inform (DECL_SOURCE_LOCATION (var),
>  	      "unnamed temporary defined here");
> 
> 	Jakub
> 
>
  

Patch

--- gcc/gimple-ssa-warn-access.cc.jj	2022-01-20 21:24:40.600955673 +0100
+++ gcc/gimple-ssa-warn-access.cc	2022-01-20 22:58:19.488226389 +0100
@@ -3953,15 +3953,14 @@  pass_waccess::warn_invalid_pointer (tree
 			    "may be used")
 		       : G_("using dangling pointer %qE to an unnamed "
 			    "temporary")),
-		      ref, var))
+		      ref))
       || (!ref
 	  && warning_at (use_loc, OPT_Wdangling_pointer_,
 			 (maybe
 			  ? G_("dangling pointer to an unnamed temporary "
 			       "may be used")
 			  : G_("using a dangling pointer to an unnamed "
-			       "temporary")),
-			 var)))
+			       "temporary")))))
     {
       inform (DECL_SOURCE_LOCATION (var),
 	      "unnamed temporary defined here");