ipa: silent -Wodr notes with -w

Message ID c210778d-e7d8-5d00-7255-329f7dfec052@suse.cz
State New
Headers
Series ipa: silent -Wodr notes with -w |

Commit Message

Martin Liška Dec. 2, 2022, 11:27 a.m. UTC
  If -w is used, warn_odr properly sets *warned = false and
so it should be preserved when calling warn_types_mismatch.

Noticed that during a LTO reduction where I used -w.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

gcc/ChangeLog:

	* ipa-devirt.cc (odr_types_equivalent_p): Respect *warned
	value if set.
---
 gcc/ipa-devirt.cc | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
  

Comments

Martin Liška Dec. 9, 2022, 8:27 a.m. UTC | #1
PING^1

On 12/2/22 12:27, Martin Liška wrote:
> If -w is used, warn_odr properly sets *warned = false and
> so it should be preserved when calling warn_types_mismatch.
> 
> Noticed that during a LTO reduction where I used -w.
> 
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
> 
> Ready to be installed?
> Thanks,
> Martin
> 
> gcc/ChangeLog:
> 
> 	* ipa-devirt.cc (odr_types_equivalent_p): Respect *warned
> 	value if set.
> ---
>  gcc/ipa-devirt.cc | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/gcc/ipa-devirt.cc b/gcc/ipa-devirt.cc
> index 265d07bb354..bcdc50c5bd7 100644
> --- a/gcc/ipa-devirt.cc
> +++ b/gcc/ipa-devirt.cc
> @@ -1300,7 +1300,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
>  	      warn_odr (t1, t2, NULL, NULL, warn, warned,
>  			G_("it is defined as a pointer to different type "
>  			   "in another translation unit"));
> -	      if (warn && warned)
> +	      if (warn && (warned == NULL || *warned))
>  	        warn_types_mismatch (TREE_TYPE (t1), TREE_TYPE (t2),
>  				     loc1, loc2);
>  	      return false;
> @@ -1315,7 +1315,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
>  	  warn_odr (t1, t2, NULL, NULL, warn, warned,
>  		    G_("a different type is defined "
>  		       "in another translation unit"));
> -	  if (warn && warned)
> +	  if (warn && (warned == NULL || *warned))
>  	    warn_types_mismatch (TREE_TYPE (t1), TREE_TYPE (t2), loc1, loc2);
>  	  return false;
>  	}
> @@ -1333,7 +1333,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
>  	    warn_odr (t1, t2, NULL, NULL, warn, warned,
>  		      G_("a different type is defined in another "
>  			 "translation unit"));
> -	    if (warn && warned)
> +	    if (warn && (warned == NULL || *warned))
>  	      warn_types_mismatch (TREE_TYPE (t1), TREE_TYPE (t2), loc1, loc2);
>  	  }
>  	gcc_assert (TYPE_STRING_FLAG (t1) == TYPE_STRING_FLAG (t2));
> @@ -1375,7 +1375,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
>  	  warn_odr (t1, t2, NULL, NULL, warn, warned,
>  		    G_("has different return value "
>  		       "in another translation unit"));
> -	  if (warn && warned)
> +	  if (warn && (warned == NULL || *warned))
>  	    warn_types_mismatch (TREE_TYPE (t1), TREE_TYPE (t2), loc1, loc2);
>  	  return false;
>  	}
> @@ -1398,7 +1398,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
>  		  warn_odr (t1, t2, NULL, NULL, warn, warned,
>  			    G_("has different parameters in another "
>  			       "translation unit"));
> -		  if (warn && warned)
> +		  if (warn && (warned == NULL || *warned))
>  		    warn_types_mismatch (TREE_VALUE (parms1),
>  					 TREE_VALUE (parms2), loc1, loc2);
>  		  return false;
> @@ -1484,7 +1484,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
>  		    warn_odr (t1, t2, f1, f2, warn, warned,
>  			      G_("a field of same name but different type "
>  				 "is defined in another translation unit"));
> -		    if (warn && warned)
> +		    if (warn && (warned == NULL || *warned))
>  		      warn_types_mismatch (TREE_TYPE (f1), TREE_TYPE (f2), loc1, loc2);
>  		    return false;
>  		  }
  
Martin Liška Dec. 22, 2022, 12:15 p.m. UTC | #2
PING^2

On 12/9/22 09:27, Martin Liška wrote:
> PING^1
> 
> On 12/2/22 12:27, Martin Liška wrote:
>> If -w is used, warn_odr properly sets *warned = false and
>> so it should be preserved when calling warn_types_mismatch.
>>
>> Noticed that during a LTO reduction where I used -w.
>>
>> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>>
>> Ready to be installed?
>> Thanks,
>> Martin
>>
>> gcc/ChangeLog:
>>
>> 	* ipa-devirt.cc (odr_types_equivalent_p): Respect *warned
>> 	value if set.
>> ---
>>  gcc/ipa-devirt.cc | 12 ++++++------
>>  1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/gcc/ipa-devirt.cc b/gcc/ipa-devirt.cc
>> index 265d07bb354..bcdc50c5bd7 100644
>> --- a/gcc/ipa-devirt.cc
>> +++ b/gcc/ipa-devirt.cc
>> @@ -1300,7 +1300,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
>>  	      warn_odr (t1, t2, NULL, NULL, warn, warned,
>>  			G_("it is defined as a pointer to different type "
>>  			   "in another translation unit"));
>> -	      if (warn && warned)
>> +	      if (warn && (warned == NULL || *warned))
>>  	        warn_types_mismatch (TREE_TYPE (t1), TREE_TYPE (t2),
>>  				     loc1, loc2);
>>  	      return false;
>> @@ -1315,7 +1315,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
>>  	  warn_odr (t1, t2, NULL, NULL, warn, warned,
>>  		    G_("a different type is defined "
>>  		       "in another translation unit"));
>> -	  if (warn && warned)
>> +	  if (warn && (warned == NULL || *warned))
>>  	    warn_types_mismatch (TREE_TYPE (t1), TREE_TYPE (t2), loc1, loc2);
>>  	  return false;
>>  	}
>> @@ -1333,7 +1333,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
>>  	    warn_odr (t1, t2, NULL, NULL, warn, warned,
>>  		      G_("a different type is defined in another "
>>  			 "translation unit"));
>> -	    if (warn && warned)
>> +	    if (warn && (warned == NULL || *warned))
>>  	      warn_types_mismatch (TREE_TYPE (t1), TREE_TYPE (t2), loc1, loc2);
>>  	  }
>>  	gcc_assert (TYPE_STRING_FLAG (t1) == TYPE_STRING_FLAG (t2));
>> @@ -1375,7 +1375,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
>>  	  warn_odr (t1, t2, NULL, NULL, warn, warned,
>>  		    G_("has different return value "
>>  		       "in another translation unit"));
>> -	  if (warn && warned)
>> +	  if (warn && (warned == NULL || *warned))
>>  	    warn_types_mismatch (TREE_TYPE (t1), TREE_TYPE (t2), loc1, loc2);
>>  	  return false;
>>  	}
>> @@ -1398,7 +1398,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
>>  		  warn_odr (t1, t2, NULL, NULL, warn, warned,
>>  			    G_("has different parameters in another "
>>  			       "translation unit"));
>> -		  if (warn && warned)
>> +		  if (warn && (warned == NULL || *warned))
>>  		    warn_types_mismatch (TREE_VALUE (parms1),
>>  					 TREE_VALUE (parms2), loc1, loc2);
>>  		  return false;
>> @@ -1484,7 +1484,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
>>  		    warn_odr (t1, t2, f1, f2, warn, warned,
>>  			      G_("a field of same name but different type "
>>  				 "is defined in another translation unit"));
>> -		    if (warn && warned)
>> +		    if (warn && (warned == NULL || *warned))
>>  		      warn_types_mismatch (TREE_TYPE (f1), TREE_TYPE (f2), loc1, loc2);
>>  		    return false;
>>  		  }
>
  
Martin Liška Jan. 13, 2023, 9:09 a.m. UTC | #3
PING^3

On 12/22/22 13:15, Martin Liška wrote:
> PING^2
> 
> On 12/9/22 09:27, Martin Liška wrote:
>> PING^1
>>
>> On 12/2/22 12:27, Martin Liška wrote:
>>> If -w is used, warn_odr properly sets *warned = false and
>>> so it should be preserved when calling warn_types_mismatch.
>>>
>>> Noticed that during a LTO reduction where I used -w.
>>>
>>> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>>>
>>> Ready to be installed?
>>> Thanks,
>>> Martin
>>>
>>> gcc/ChangeLog:
>>>
>>> 	* ipa-devirt.cc (odr_types_equivalent_p): Respect *warned
>>> 	value if set.
>>> ---
>>>   gcc/ipa-devirt.cc | 12 ++++++------
>>>   1 file changed, 6 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/gcc/ipa-devirt.cc b/gcc/ipa-devirt.cc
>>> index 265d07bb354..bcdc50c5bd7 100644
>>> --- a/gcc/ipa-devirt.cc
>>> +++ b/gcc/ipa-devirt.cc
>>> @@ -1300,7 +1300,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
>>>   	      warn_odr (t1, t2, NULL, NULL, warn, warned,
>>>   			G_("it is defined as a pointer to different type "
>>>   			   "in another translation unit"));
>>> -	      if (warn && warned)
>>> +	      if (warn && (warned == NULL || *warned))
>>>   	        warn_types_mismatch (TREE_TYPE (t1), TREE_TYPE (t2),
>>>   				     loc1, loc2);
>>>   	      return false;
>>> @@ -1315,7 +1315,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
>>>   	  warn_odr (t1, t2, NULL, NULL, warn, warned,
>>>   		    G_("a different type is defined "
>>>   		       "in another translation unit"));
>>> -	  if (warn && warned)
>>> +	  if (warn && (warned == NULL || *warned))
>>>   	    warn_types_mismatch (TREE_TYPE (t1), TREE_TYPE (t2), loc1, loc2);
>>>   	  return false;
>>>   	}
>>> @@ -1333,7 +1333,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
>>>   	    warn_odr (t1, t2, NULL, NULL, warn, warned,
>>>   		      G_("a different type is defined in another "
>>>   			 "translation unit"));
>>> -	    if (warn && warned)
>>> +	    if (warn && (warned == NULL || *warned))
>>>   	      warn_types_mismatch (TREE_TYPE (t1), TREE_TYPE (t2), loc1, loc2);
>>>   	  }
>>>   	gcc_assert (TYPE_STRING_FLAG (t1) == TYPE_STRING_FLAG (t2));
>>> @@ -1375,7 +1375,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
>>>   	  warn_odr (t1, t2, NULL, NULL, warn, warned,
>>>   		    G_("has different return value "
>>>   		       "in another translation unit"));
>>> -	  if (warn && warned)
>>> +	  if (warn && (warned == NULL || *warned))
>>>   	    warn_types_mismatch (TREE_TYPE (t1), TREE_TYPE (t2), loc1, loc2);
>>>   	  return false;
>>>   	}
>>> @@ -1398,7 +1398,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
>>>   		  warn_odr (t1, t2, NULL, NULL, warn, warned,
>>>   			    G_("has different parameters in another "
>>>   			       "translation unit"));
>>> -		  if (warn && warned)
>>> +		  if (warn && (warned == NULL || *warned))
>>>   		    warn_types_mismatch (TREE_VALUE (parms1),
>>>   					 TREE_VALUE (parms2), loc1, loc2);
>>>   		  return false;
>>> @@ -1484,7 +1484,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
>>>   		    warn_odr (t1, t2, f1, f2, warn, warned,
>>>   			      G_("a field of same name but different type "
>>>   				 "is defined in another translation unit"));
>>> -		    if (warn && warned)
>>> +		    if (warn && (warned == NULL || *warned))
>>>   		      warn_types_mismatch (TREE_TYPE (f1), TREE_TYPE (f2), loc1, loc2);
>>>   		    return false;
>>>   		  }
>>
>
  
Martin Liška Jan. 24, 2023, 1:34 p.m. UTC | #4
PING^4

On 1/13/23 10:09, Martin Liška wrote:
> PING^3
> 
> On 12/22/22 13:15, Martin Liška wrote:
>> PING^2
>>
>> On 12/9/22 09:27, Martin Liška wrote:
>>> PING^1
>>>
>>> On 12/2/22 12:27, Martin Liška wrote:
>>>> If -w is used, warn_odr properly sets *warned = false and
>>>> so it should be preserved when calling warn_types_mismatch.
>>>>
>>>> Noticed that during a LTO reduction where I used -w.
>>>>
>>>> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>>>>
>>>> Ready to be installed?
>>>> Thanks,
>>>> Martin
>>>>
>>>> gcc/ChangeLog:
>>>>
>>>>     * ipa-devirt.cc (odr_types_equivalent_p): Respect *warned
>>>>     value if set.
>>>> ---
>>>>   gcc/ipa-devirt.cc | 12 ++++++------
>>>>   1 file changed, 6 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/gcc/ipa-devirt.cc b/gcc/ipa-devirt.cc
>>>> index 265d07bb354..bcdc50c5bd7 100644
>>>> --- a/gcc/ipa-devirt.cc
>>>> +++ b/gcc/ipa-devirt.cc
>>>> @@ -1300,7 +1300,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
>>>>             warn_odr (t1, t2, NULL, NULL, warn, warned,
>>>>               G_("it is defined as a pointer to different type "
>>>>                  "in another translation unit"));
>>>> -          if (warn && warned)
>>>> +          if (warn && (warned == NULL || *warned))
>>>>               warn_types_mismatch (TREE_TYPE (t1), TREE_TYPE (t2),
>>>>                        loc1, loc2);
>>>>             return false;
>>>> @@ -1315,7 +1315,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
>>>>         warn_odr (t1, t2, NULL, NULL, warn, warned,
>>>>               G_("a different type is defined "
>>>>                  "in another translation unit"));
>>>> -      if (warn && warned)
>>>> +      if (warn && (warned == NULL || *warned))
>>>>           warn_types_mismatch (TREE_TYPE (t1), TREE_TYPE (t2), loc1, loc2);
>>>>         return false;
>>>>       }
>>>> @@ -1333,7 +1333,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
>>>>           warn_odr (t1, t2, NULL, NULL, warn, warned,
>>>>                 G_("a different type is defined in another "
>>>>                "translation unit"));
>>>> -        if (warn && warned)
>>>> +        if (warn && (warned == NULL || *warned))
>>>>             warn_types_mismatch (TREE_TYPE (t1), TREE_TYPE (t2), loc1, loc2);
>>>>         }
>>>>       gcc_assert (TYPE_STRING_FLAG (t1) == TYPE_STRING_FLAG (t2));
>>>> @@ -1375,7 +1375,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
>>>>         warn_odr (t1, t2, NULL, NULL, warn, warned,
>>>>               G_("has different return value "
>>>>                  "in another translation unit"));
>>>> -      if (warn && warned)
>>>> +      if (warn && (warned == NULL || *warned))
>>>>           warn_types_mismatch (TREE_TYPE (t1), TREE_TYPE (t2), loc1, loc2);
>>>>         return false;
>>>>       }
>>>> @@ -1398,7 +1398,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
>>>>             warn_odr (t1, t2, NULL, NULL, warn, warned,
>>>>                   G_("has different parameters in another "
>>>>                      "translation unit"));
>>>> -          if (warn && warned)
>>>> +          if (warn && (warned == NULL || *warned))
>>>>               warn_types_mismatch (TREE_VALUE (parms1),
>>>>                        TREE_VALUE (parms2), loc1, loc2);
>>>>             return false;
>>>> @@ -1484,7 +1484,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
>>>>               warn_odr (t1, t2, f1, f2, warn, warned,
>>>>                     G_("a field of same name but different type "
>>>>                    "is defined in another translation unit"));
>>>> -            if (warn && warned)
>>>> +            if (warn && (warned == NULL || *warned))
>>>>                 warn_types_mismatch (TREE_TYPE (f1), TREE_TYPE (f2), loc1, loc2);
>>>>               return false;
>>>>             }
>>>
>>
>
  

Patch

diff --git a/gcc/ipa-devirt.cc b/gcc/ipa-devirt.cc
index 265d07bb354..bcdc50c5bd7 100644
--- a/gcc/ipa-devirt.cc
+++ b/gcc/ipa-devirt.cc
@@ -1300,7 +1300,7 @@  odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
 	      warn_odr (t1, t2, NULL, NULL, warn, warned,
 			G_("it is defined as a pointer to different type "
 			   "in another translation unit"));
-	      if (warn && warned)
+	      if (warn && (warned == NULL || *warned))
 	        warn_types_mismatch (TREE_TYPE (t1), TREE_TYPE (t2),
 				     loc1, loc2);
 	      return false;
@@ -1315,7 +1315,7 @@  odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
 	  warn_odr (t1, t2, NULL, NULL, warn, warned,
 		    G_("a different type is defined "
 		       "in another translation unit"));
-	  if (warn && warned)
+	  if (warn && (warned == NULL || *warned))
 	    warn_types_mismatch (TREE_TYPE (t1), TREE_TYPE (t2), loc1, loc2);
 	  return false;
 	}
@@ -1333,7 +1333,7 @@  odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
 	    warn_odr (t1, t2, NULL, NULL, warn, warned,
 		      G_("a different type is defined in another "
 			 "translation unit"));
-	    if (warn && warned)
+	    if (warn && (warned == NULL || *warned))
 	      warn_types_mismatch (TREE_TYPE (t1), TREE_TYPE (t2), loc1, loc2);
 	  }
 	gcc_assert (TYPE_STRING_FLAG (t1) == TYPE_STRING_FLAG (t2));
@@ -1375,7 +1375,7 @@  odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
 	  warn_odr (t1, t2, NULL, NULL, warn, warned,
 		    G_("has different return value "
 		       "in another translation unit"));
-	  if (warn && warned)
+	  if (warn && (warned == NULL || *warned))
 	    warn_types_mismatch (TREE_TYPE (t1), TREE_TYPE (t2), loc1, loc2);
 	  return false;
 	}
@@ -1398,7 +1398,7 @@  odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
 		  warn_odr (t1, t2, NULL, NULL, warn, warned,
 			    G_("has different parameters in another "
 			       "translation unit"));
-		  if (warn && warned)
+		  if (warn && (warned == NULL || *warned))
 		    warn_types_mismatch (TREE_VALUE (parms1),
 					 TREE_VALUE (parms2), loc1, loc2);
 		  return false;
@@ -1484,7 +1484,7 @@  odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
 		    warn_odr (t1, t2, f1, f2, warn, warned,
 			      G_("a field of same name but different type "
 				 "is defined in another translation unit"));
-		    if (warn && warned)
+		    if (warn && (warned == NULL || *warned))
 		      warn_types_mismatch (TREE_TYPE (f1), TREE_TYPE (f2), loc1, loc2);
 		    return false;
 		  }