c-common.c (shorten_compare): Don't -Wtype-limits if the non-constant operand comes from a macro.
* c-common.c (shorten_compare): Don't -Wtype-limits if the non-constant operand comes from a macro. From-SVN: r230589
This commit is contained in:
parent
7d7e7aca3b
commit
d0eccfcdc3
3 changed files with 19 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
|||
2015-11-18 Jason Merrill <jason@redhat.com>
|
||||
|
||||
* c-common.c (shorten_compare): Don't -Wtype-limits if the
|
||||
non-constant operand comes from a macro.
|
||||
|
||||
2015-11-17 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR bootstrap/68346
|
||||
|
|
|
@ -4650,7 +4650,9 @@ shorten_compare (location_t loc, tree *op0_ptr, tree *op1_ptr,
|
|||
type = c_common_unsigned_type (type);
|
||||
}
|
||||
|
||||
if (TREE_CODE (primop0) != INTEGER_CST)
|
||||
if (TREE_CODE (primop0) != INTEGER_CST
|
||||
/* Don't warn if it's from a macro. */
|
||||
&& !from_macro_expansion_at (EXPR_LOCATION (primop0)))
|
||||
{
|
||||
if (val == truthvalue_false_node)
|
||||
warning_at (loc, OPT_Wtype_limits,
|
||||
|
|
11
gcc/testsuite/g++.dg/warn/Wtype-limits2.C
Normal file
11
gcc/testsuite/g++.dg/warn/Wtype-limits2.C
Normal file
|
@ -0,0 +1,11 @@
|
|||
// { dg-options -Wtype-limits }
|
||||
|
||||
unsigned char array[4];
|
||||
bool b;
|
||||
#define VAL (b ? array[0] : (unsigned char)0)
|
||||
|
||||
int main()
|
||||
{
|
||||
if (VAL > 1000)
|
||||
__builtin_abort();
|
||||
}
|
Loading…
Add table
Reference in a new issue