c-common.c (shorten_compare): But look through macros from system headers.

* c-common.c (shorten_compare): But look through macros from
	system headers.

From-SVN: r230665
This commit is contained in:
Jason Merrill
2015-11-20 10:51:35 -05:00
committed by Jason Merrill
parent 8e92560a9c
commit 269adb9dea
3 changed files with 21 additions and 2 deletions

View File

@@ -1,3 +1,8 @@
2015-11-19 Jason Merrill <jason@redhat.com>
* c-common.c (shorten_compare): But look through macros from
system headers.
2015-11-18 Jason Merrill <jason@redhat.com>
* c-common.c (shorten_compare): Don't -Wtype-limits if the

View File

@@ -4651,8 +4651,10 @@ shorten_compare (location_t loc, tree *op0_ptr, tree *op1_ptr,
}
if (TREE_CODE (primop0) != INTEGER_CST
/* Don't warn if it's from a macro. */
&& !from_macro_expansion_at (EXPR_LOCATION (primop0)))
/* Don't warn if it's from a (non-system) macro. */
&& !(from_macro_expansion_at
(expansion_point_location_if_in_system_header
(EXPR_LOCATION (primop0)))))
{
if (val == truthvalue_false_node)
warning_at (loc, OPT_Wtype_limits,

View File

@@ -0,0 +1,12 @@
/* { dg-do compile } */
/* { dg-options "-Wtype-limits" } */
/* { dg-require-effective-target sync_char_short } */
#include <stdatomic.h>
unsigned foo (unsigned char *x)
{
if (atomic_load (x) > 1000) /* { dg-warning "comparison is always false due to limited range of data type" } */
return 0;
return 1;
}