From: David Malcolm Date: Mon, 3 Feb 2020 11:34:20 +0000 (-0500) Subject: analyzer: fix ICE due to comparing int and real constants (PR 93547) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=287ccd3bd6b92f11ec90c52ffccb764aacfadb89;p=gcc.git 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. --- diff --git a/gcc/analyzer/ChangeLog b/gcc/analyzer/ChangeLog index 66d46b0dc82..ac6fc1a30fc 100644 --- a/gcc/analyzer/ChangeLog +++ b/gcc/analyzer/ChangeLog @@ -1,3 +1,10 @@ +2020-02-03 David Malcolm + + 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 PR analyzer/93457 diff --git a/gcc/analyzer/constraint-manager.cc b/gcc/analyzer/constraint-manager.cc index f3e31ee0830..4042c50fcb7 100644 --- a/gcc/analyzer/constraint-manager.cc +++ b/gcc/analyzer/constraint-manager.cc @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cc9f3c15f85..94e83da480b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-02-03 David Malcolm + + PR analyzer/93547 + * gcc.dg/analyzer/pr93547.c: New test. + 2020-02-03 Stam Markianos-Wright PR target/91816 diff --git a/gcc/testsuite/gcc.dg/analyzer/pr93547.c b/gcc/testsuite/gcc.dg/analyzer/pr93547.c new file mode 100644 index 00000000000..15189048234 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/pr93547.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ + +void +wy (int); + +int +f9 (void) +{ + int p5 = __builtin_ilogb (__builtin_inf ()); + + wy (0); + + return p5; +}