From a619c58fb6ebe25ab2a69a959ac1309bacf241cf Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Thu, 18 Jun 2020 07:51:29 -0400 Subject: [PATCH 237/315] FIXME: remove self-comparisons due to EC mergers --- gcc/analyzer/constraint-manager2.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gcc/analyzer/constraint-manager2.cc b/gcc/analyzer/constraint-manager2.cc index 8f12cfcf51b..7e09e69d869 100644 --- a/gcc/analyzer/constraint-manager2.cc +++ b/gcc/analyzer/constraint-manager2.cc @@ -843,6 +843,12 @@ constraint_manager2::add_constraint (equiv_class2_id lhs_ec_id, if (c->m_rhs == final_ec_id) c->m_rhs = rhs_ec_id; } + + /* We may now have self-comparisons due to the merger; these + constraints should be removed. */ + unsigned read_index, write_index; + VEC_ORDERED_REMOVE_IF (m_constraints, read_index, write_index, c, + (c->m_lhs == c->m_rhs)); } break; case GE_EXPR: @@ -2218,6 +2224,10 @@ test_transitivity () // TODO: ASSERT_CONDITION_TRUE2 (model, a, EQ_EXPR, b); + + /* The ECs for a and b should have merged, and any constraints removed. */ + ASSERT_EQ (model.get_constraints2 ()->m_equiv_classes.length (), 1); + ASSERT_EQ (model.get_constraints2 ()->m_constraints.length (), 0); } /* Transitivity: "a >= b", "b > a" should be impossible. */ -- 2.26.2