public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r10-6368] analyzer: further fixes for comparisons between uncomparable types (PR 93450)
@ 2020-01-31 13:24 David Malcolm
  0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2020-01-31 13:24 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:45eb3e4944ba93b1d4e9070c703068cfa7aaace4

commit r10-6368-g45eb3e4944ba93b1d4e9070c703068cfa7aaace4
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Thu Jan 30 15:21:28 2020 -0500

    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.

Diff:
---
 gcc/analyzer/ChangeLog             | 9 +++++++++
 gcc/analyzer/constraint-manager.cc | 4 +++-
 gcc/analyzer/region-model.cc       | 2 +-
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/gcc/analyzer/ChangeLog b/gcc/analyzer/ChangeLog
index 709d1cb..7ca6c22 100644
--- a/gcc/analyzer/ChangeLog
+++ b/gcc/analyzer/ChangeLog
@@ -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.
diff --git a/gcc/analyzer/constraint-manager.cc b/gcc/analyzer/constraint-manager.cc
index 777bd1b..f3e31ee 100644
--- a/gcc/analyzer/constraint-manager.cc
+++ b/gcc/analyzer/constraint-manager.cc
@@ -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).
diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc
index a15088a..b546114 100644
--- a/gcc/analyzer/region-model.cc
+++ b/gcc/analyzer/region-model.cc
@@ -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);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-01-31 13:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-31 13:24 [gcc r10-6368] analyzer: further fixes for comparisons between uncomparable types (PR 93450) David Malcolm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).