Commit 173864e8 by Marek Polacek Committed by Marek Polacek

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
parent 53a19317
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
......
......@@ -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;
......
2015-07-30 Marek Polacek <polacek@redhat.com>
* c-c++-common/Wtautological-compare-3.c: New test.
2015-07-29 Alan Lawrence <alan.lawrence@arm.com>
* gcc.target/aarch64/vld1_lane.c (main): Remove unused test data.
......
/* { dg-do compile } */
/* { dg-options "-Wtautological-compare" } */
/* Test we don't warn for floats. */
struct S { double d; float f; };
void
fn1 (int i, float f, double d, struct S *s, float *fp)
{
if (f == f);
if (f != f);
if (d == d);
if (d != d);
if (fp[i] == fp[i]);
if (fp[i] != fp[i]);
if (s->f == s->f);
if (s->f != s->f);
if (s->d == s->d);
if (s->d != s->d);
}
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