Commit 45eb3e49 by David Malcolm

analyzer: further fixes for comparisons between uncomparable types (PR 93450)

gcc/analyzer/ChangeLog:
	PR analyzer/93450
	* constraint-manager.cc
	(constraint_manager::get_or_add_equiv_class): Only compare constants
	if their types are compatible.
	* region-model.cc (constant_svalue::eval_condition): Replace check
	for identical types with call to types_compatible_p.
parent 95607c12
2020-01-31 David Malcolm <dmalcolm@redhat.com>
PR analyzer/93450
* constraint-manager.cc
(constraint_manager::get_or_add_equiv_class): Only compare constants
if their types are compatible.
* region-model.cc (constant_svalue::eval_condition): Replace check
for identical types with call to types_compatible_p.
2020-01-30 David Malcolm <dmalcolm@redhat.com> 2020-01-30 David Malcolm <dmalcolm@redhat.com>
* program-state.cc (extrinsic_state::dump_to_pp): New. * program-state.cc (extrinsic_state::dump_to_pp): New.
......
...@@ -958,7 +958,9 @@ constraint_manager::get_or_add_equiv_class (svalue_id sid) ...@@ -958,7 +958,9 @@ constraint_manager::get_or_add_equiv_class (svalue_id sid)
other_id.m_idx++) other_id.m_idx++)
{ {
const equiv_class &other_ec = other_id.get_obj (*this); const equiv_class &other_ec = other_id.get_obj (*this);
if (other_ec.m_constant) if (other_ec.m_constant
&& types_compatible_p (TREE_TYPE (new_ec->m_constant),
TREE_TYPE (other_ec.m_constant)))
{ {
/* If we have two ECs, both with constants, the constants must be /* If we have two ECs, both with constants, the constants must be
non-equal (or they would be in the same EC). non-equal (or they would be in the same EC).
......
...@@ -667,7 +667,7 @@ constant_svalue::eval_condition (constant_svalue *lhs, ...@@ -667,7 +667,7 @@ constant_svalue::eval_condition (constant_svalue *lhs,
gcc_assert (CONSTANT_CLASS_P (rhs_const)); gcc_assert (CONSTANT_CLASS_P (rhs_const));
/* Check for comparable types. */ /* Check for comparable types. */
if (TREE_TYPE (lhs_const) == TREE_TYPE (rhs_const)) if (types_compatible_p (TREE_TYPE (lhs_const), TREE_TYPE (rhs_const)))
{ {
tree comparison tree comparison
= fold_build2 (op, boolean_type_node, lhs_const, rhs_const); = fold_build2 (op, boolean_type_node, lhs_const, rhs_const);
......
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