This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH to shorten_compare -Wtype-limits handling
- From: Martin Sebor <msebor at gmail dot com>
- To: Jason Merrill <jason at redhat dot com>, gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Cc: David Edelsohn <dje dot gcc at gmail dot com>, Manuel LÃpez-IbÃÃez <manu at gcc dot gnu dot org>
- Date: Thu, 19 Nov 2015 12:44:23 -0700
- Subject: Re: PATCH to shorten_compare -Wtype-limits handling
- Authentication-results: sourceware.org; auth=none
- References: <564D4F77 dot 3010005 at redhat dot com>
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?
#include <stdatomic.h>
unsigned foo (unsigned char *x)
{
if (atomic_load (x) > 1000)
return 0;
return 1;
}
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)
return 0;
return 1;
}
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).
There is also code in tree-vrp.c that issues it unconditionally
regardless of macros or system headers.
Martin