Commit 269adb9d by Jason Merrill Committed by Jason Merrill

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
parent 8e92560a
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
......
......@@ -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,
......
/* { 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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment