analyzer: fix ICE due to comparing int and real constants (PR 93547)

gcc/analyzer/ChangeLog:
	PR analyzer/93547
	* constraint-manager.cc
	(constraint_manager::get_or_add_equiv_class): Ensure types are
	compatible before comparing constants.

gcc/testsuite/ChangeLog:
	PR analyzer/93547
	* gcc.dg/analyzer/pr93547.c: New test.
This commit is contained in:
David Malcolm 2020-02-03 06:34:20 -05:00
parent e01975f97c
commit 287ccd3bd6
4 changed files with 29 additions and 1 deletions

View File

@ -1,3 +1,10 @@
2020-02-03 David Malcolm <dmalcolm@redhat.com>
PR analyzer/93547
* constraint-manager.cc
(constraint_manager::get_or_add_equiv_class): Ensure types are
compatible before comparing constants.
2020-01-31 David Malcolm <dmalcolm@redhat.com>
PR analyzer/93457

View File

@ -928,7 +928,9 @@ constraint_manager::get_or_add_equiv_class (svalue_id sid)
int i;
equiv_class *ec;
FOR_EACH_VEC_ELT (m_equiv_classes, i, ec)
if (ec->m_constant)
if (ec->m_constant
&& types_compatible_p (TREE_TYPE (cst),
TREE_TYPE (ec->m_constant)))
{
tree eq = fold_build2 (EQ_EXPR, boolean_type_node,
cst, ec->m_constant);

View File

@ -1,3 +1,8 @@
2020-02-03 David Malcolm <dmalcolm@redhat.com>
PR analyzer/93547
* gcc.dg/analyzer/pr93547.c: New test.
2020-02-03 Stam Markianos-Wright <stam.markianos-wright@arm.com>
PR target/91816

View File

@ -0,0 +1,14 @@
/* { dg-do compile } */
void
wy (int);
int
f9 (void)
{
int p5 = __builtin_ilogb (__builtin_inf ());
wy (0);
return p5;
}