diff options
author | Marek Polacek <polacek@redhat.com> | 2015-07-30 08:31:59 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2015-07-30 08:31:59 +0000 |
commit | 173864e8f143d138c2805c03699d8d58b2c970c8 (patch) | |
tree | 6d585d350099dc5419318d05edf0701334efd02c /gcc/c-family | |
parent | 53a19317f40159b3fd96391a87182c8e0c7072c4 (diff) | |
download | gcc-173864e8f143d138c2805c03699d8d58b2c970c8.zip gcc-173864e8f143d138c2805c03699d8d58b2c970c8.tar.gz gcc-173864e8f143d138c2805c03699d8d58b2c970c8.tar.bz2 |
c-common.c (warn_tautological_cmp): Bail for float types.
* c-common.c (warn_tautological_cmp): Bail for float types.
* c-c++-common/Wtautological-compare-3.c: New test.
From-SVN: r226388
Diffstat (limited to 'gcc/c-family')
-rw-r--r-- | gcc/c-family/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/c-family/c-common.c | 6 |
2 files changed, 10 insertions, 0 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 06853ea..d895394 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,7 @@ +2015-07-30 Marek Polacek <polacek@redhat.com> + + * c-common.c (warn_tautological_cmp): Bail for float types. + 2015-07-27 Marek Polacek <polacek@redhat.com> PR bootstrap/67030 diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index caa801e..a8e5353 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -1910,6 +1910,12 @@ warn_tautological_cmp (location_t loc, enum tree_code code, tree lhs, tree rhs) || (CONVERT_EXPR_P (rhs) || TREE_CODE (rhs) == NON_LVALUE_EXPR)) return; + /* Don't warn if either LHS or RHS has an IEEE floating-point type. + It could be a NaN, and NaN never compares equal to anything, even + itself. */ + if (FLOAT_TYPE_P (TREE_TYPE (lhs)) || FLOAT_TYPE_P (TREE_TYPE (rhs))) + return; + if (operand_equal_p (lhs, rhs, 0)) { /* Don't warn about array references with constant indices; |