analyzer: further fixes for comparisons between uncomparable types (PR 93450)
authorDavid Malcolm <dmalcolm@redhat.com>
Thu, 30 Jan 2020 20:21:28 +0000 (15:21 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Fri, 31 Jan 2020 13:23:28 +0000 (08:23 -0500)
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.

gcc/analyzer/ChangeLog
gcc/analyzer/constraint-manager.cc
gcc/analyzer/region-model.cc

index 709d1cb913f7ffbe0191a167d9eb6609e3ab5e12..7ca6c2217e31a476b1e024d52422d65954db5903 100644 (file)
@@ -1,3 +1,12 @@
+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>
 
        * program-state.cc (extrinsic_state::dump_to_pp): New.
index 777bd1b13c9bd989767fa4593d1e12ddcbc0ee7c..f3e31ee083071de68c8393bdac1f4d3ce792a3f4 100644 (file)
@@ -958,7 +958,9 @@ constraint_manager::get_or_add_equiv_class (svalue_id sid)
           other_id.m_idx++)
        {
          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
                 non-equal (or they would be in the same EC).
index a15088a2e3cfe417347fceed5e3bea0bdbc3634b..b546114bfd5b7947afd44a20c3bc2b26ab4909f5 100644 (file)
@@ -667,7 +667,7 @@ constant_svalue::eval_condition (constant_svalue *lhs,
   gcc_assert (CONSTANT_CLASS_P (rhs_const));
 
   /* 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
        = fold_build2 (op, boolean_type_node, lhs_const, rhs_const);