PATCH to shorten_compare -Wtype-limits handling

Jason Merrill
Thu Nov 19 22:16:00 GMT 2015

On 11/19/2015 02:44 PM, Martin Sebor wrote:
> On 11/18/2015 09:26 PM, Jason Merrill wrote:
>> The rs6000 target was hitting a bootstrap failure due to
>> -Werror=type-limits.  Since warn_tautological_cmp and other warnings
>> avoid warning if one of the operands comes from a macro, I thought it
>> would make sense to do that here as well.
> The also disables the warning for functions that are shadowed by
> macros such as C atomic_load et al. For example, in the program
> below. Is that an acceptable compromise or is there a way to avoid
> this?

I think it's an acceptable compromise, but see below.

> At the same time, the change doesn't suppress the warning in other
> cases where I would have expected it to suppress it based on your
> description. For instance here:
>    unsigned short bar (unsigned short x)
>    {
>    #define X x
>      if (x > 0xffff)

Yes, this is missed because the front end doesn't remember the location 
of the use of x; that's one of many location tracking issues.  David 
Malcolm is working on this stuff.

> I noticed there is code elsewhere in c-common.c that avoids
> issuing the same warning for system headers (that's the code
> that responsible for issuing the warning for the second test
> case above).

Hmm, it looks like using expansion_point_if_in_system_header might avoid 
the first issue you mention.

> There is also code in tree-vrp.c that issues it unconditionally
> regardless of macros or system headers.

Good to know.


More information about the Gcc-patches mailing list