mirror of
https://github.com/gcc-mirror/gcc.git
synced 2026-05-06 14:59:39 +02:00
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:
committed by
Jason Merrill
parent
8e92560a9c
commit
269adb9dea
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
12
gcc/testsuite/gcc.dg/Wtype-limits2.c
Normal file
12
gcc/testsuite/gcc.dg/Wtype-limits2.c
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user