+2020-01-30 David Malcolm <dmalcolm@redhat.com>
+
+ PR analyzer/93356
+ * doc/analyzer.texi (Limitations): Note that constraints on
+ floating-point values are currently ignored.
+
2020-01-30 Jakub Jelinek <jakub@redhat.com>
PR lto/93384
+2020-01-30 David Malcolm <dmalcolm@redhat.com>
+
+ PR analyzer/93356
+ * region-model.cc (region_model::eval_condition): In both
+ overloads, bail out immediately on floating-point types.
+ (region_model::eval_condition_without_cm): Likewise.
+ (region_model::add_constraint): Likewise.
+
2020-01-30 David Malcolm <dmalcolm@redhat.com>
PR analyzer/93450
enum tree_code op,
svalue_id rhs_sid) const
{
+ svalue *lhs = get_svalue (lhs_sid);
+ svalue *rhs = get_svalue (rhs_sid);
+
+ /* For now, make no attempt to capture constraints on floating-point
+ values. */
+ if ((lhs->get_type () && FLOAT_TYPE_P (lhs->get_type ()))
+ || (rhs->get_type () && FLOAT_TYPE_P (rhs->get_type ())))
+ return tristate::unknown ();
+
tristate ts = eval_condition_without_cm (lhs_sid, op, rhs_sid);
if (ts.is_known ())
/* See what we know based on the values. */
if (lhs && rhs)
{
+ /* For now, make no attempt to capture constraints on floating-point
+ values. */
+ if ((lhs->get_type () && FLOAT_TYPE_P (lhs->get_type ()))
+ || (rhs->get_type () && FLOAT_TYPE_P (rhs->get_type ())))
+ return tristate::unknown ();
+
if (lhs == rhs)
{
/* If we have the same svalue, then we have equality
region_model::add_constraint (tree lhs, enum tree_code op, tree rhs,
region_model_context *ctxt)
{
+ /* For now, make no attempt to capture constraints on floating-point
+ values. */
+ if (FLOAT_TYPE_P (TREE_TYPE (lhs)) || FLOAT_TYPE_P (TREE_TYPE (rhs)))
+ return true;
+
svalue_id lhs_sid = get_rvalue (lhs, ctxt);
svalue_id rhs_sid = get_rvalue (rhs, ctxt);
tree rhs,
region_model_context *ctxt)
{
+ /* For now, make no attempt to model constraints on floating-point
+ values. */
+ if (FLOAT_TYPE_P (TREE_TYPE (lhs)) || FLOAT_TYPE_P (TREE_TYPE (rhs)))
+ return tristate::unknown ();
+
return eval_condition (get_rvalue (lhs, ctxt), op, get_rvalue (rhs, ctxt));
}
@item
The constraint-handling code assumes reflexivity in some places
(that values are equal to themselves), which is not the case for NaN.
+As a simple workaround, constraints on floating-point values are
+currently ignored.
@item
The region model code creates lots of little mutable objects at each
@code{region_model} (and thus per @code{exploded_node}) rather than
-2020-01-30 Jeff Law <law@redhat.com
+2020-01-30 David Malcolm <dmalcolm@redhat.com>
+
+ PR analyzer/93356
+ * gcc.dg/analyzer/conditionals-notrans.c (test_float_selfcmp):
+ Add.
+ * gcc.dg/analyzer/conditionals-trans.c: Mark floating point
+ comparison test as failing.
+ (test_float_selfcmp): Add.
+ * gcc.dg/analyzer/data-model-1.c: Mark floating point comparison
+ tests as failing.
+ * gcc.dg/analyzer/torture/pr93356.c: New test.
+
+2020-01-30 Jeff Law <law@redhat.com>
PR c/88660
* gcc.dg/pr88660.c: New test
__analyzer_eval (f == 4); /* { dg-warning "TRUE" "desired" { xfail *-*-* } } */
/* { dg-bogus "UNKNOWN" "status quo" { xfail *-*-* } .-1 } */
}
+
+void test_float_selfcmp (float f)
+{
+ __analyzer_eval (f == f); /* { dg-warning "UNKNOWN" } */
+ __analyzer_eval (f != f); /* { dg-warning "UNKNOWN" } */
+}
{
if (f >= 4)
if (f <= 4)
- __analyzer_eval (f == 4); /* { dg-warning "TRUE" } */
+ __analyzer_eval (f == 4); /* { dg-warning "TRUE" "PR 93356" { xfail *-*-* } } */
+ /* { dg-warning "UNKNOWN" "disabled float comparisons" { target *-*-* } .-1 } */
+}
+
+void test_float_selfcmp (float f)
+{
+ __analyzer_eval (f == f); /* { dg-warning "UNKNOWN" } */
+ __analyzer_eval (f != f); /* { dg-warning "UNKNOWN" } */
}
{
__analyzer_eval (o->mid.in.f == 0.f); /* { dg-warning "UNKNOWN" } */
o->mid.in.f = 0.f;
- __analyzer_eval (o->mid.in.f == 0.f); /* { dg-warning "TRUE" } */
+ __analyzer_eval (o->mid.in.f == 0.f); /* { dg-warning "TRUE" "PR 93356" { xfail *-*-* } } */
+ /* { dg-warning "UNKNOWN" "disabled float comparisons" { target *-*-* } .-1 } */
}
void test_14 (struct outer o)
{
__analyzer_eval (o.mid.in.f == 0.f); /* { dg-warning "UNKNOWN" } */
o.mid.in.f = 0.f;
- __analyzer_eval (o.mid.in.f == 0.f); /* { dg-warning "TRUE" } */
+ __analyzer_eval (o.mid.in.f == 0.f); /* { dg-warning "TRUE" "PR 93356" { xfail *-*-* } } */
+ /* { dg-warning "UNKNOWN" "disabled float comparisons" { target *-*-* } .-1 } */
}
void test_15 (const char *str)
float f;
i = 42;
f = i;
- __analyzer_eval (f == 42.0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (f == 42.0); /* { dg-warning "TRUE" "PR 93356" { xfail *-*-* } } */
+ /* { dg-warning "UNKNOWN" "disabled float comparisons" { target *-*-* } .-1 } */
}
void test_43 (void)
--- /dev/null
+void
+test (double d)
+{
+ if (__builtin_isnan (d))
+ return;
+}