analyzer: fix ICE on vector comparisons [PR96713]
gcc/analyzer/ChangeLog: PR analyzer/96713 * region-model.cc (region_model::get_gassign_result): For comparisons, only use eval_condition when the lhs has boolean type, and use get_or_create_constant_svalue on the boolean constants directly rather than via get_rvalue. gcc/testsuite/ChangeLog: PR analyzer/96713 * gcc.dg/analyzer/pr96713.c: New test.
This commit is contained in:
parent
04e23a4051
commit
2f5951bd95
@ -462,24 +462,23 @@ region_model::get_gassign_result (const gassign *assign,
|
|||||||
{
|
{
|
||||||
tree rhs2 = gimple_assign_rhs2 (assign);
|
tree rhs2 = gimple_assign_rhs2 (assign);
|
||||||
|
|
||||||
// TODO: constraints between svalues
|
|
||||||
const svalue *rhs1_sval = get_rvalue (rhs1, ctxt);
|
const svalue *rhs1_sval = get_rvalue (rhs1, ctxt);
|
||||||
const svalue *rhs2_sval = get_rvalue (rhs2, ctxt);
|
const svalue *rhs2_sval = get_rvalue (rhs2, ctxt);
|
||||||
|
|
||||||
tristate t = eval_condition (rhs1_sval, op, rhs2_sval);
|
if (TREE_TYPE (lhs) == boolean_type_node)
|
||||||
if (t.is_known ())
|
|
||||||
return get_rvalue (t.is_true ()
|
|
||||||
? boolean_true_node
|
|
||||||
: boolean_false_node,
|
|
||||||
ctxt);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// TODO: symbolic value for binop
|
/* Consider constraints between svalues. */
|
||||||
const svalue *sval_binop
|
tristate t = eval_condition (rhs1_sval, op, rhs2_sval);
|
||||||
= m_mgr->get_or_create_binop (TREE_TYPE (lhs), op,
|
if (t.is_known ())
|
||||||
rhs1_sval, rhs2_sval);
|
return m_mgr->get_or_create_constant_svalue
|
||||||
return sval_binop;
|
(t.is_true () ? boolean_true_node : boolean_false_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Otherwise, generate a symbolic binary op. */
|
||||||
|
const svalue *sval_binop
|
||||||
|
= m_mgr->get_or_create_binop (TREE_TYPE (lhs), op,
|
||||||
|
rhs1_sval, rhs2_sval);
|
||||||
|
return sval_binop;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
8
gcc/testsuite/gcc.dg/analyzer/pr96713.c
Normal file
8
gcc/testsuite/gcc.dg/analyzer/pr96713.c
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
typedef int __attribute__ ((vector_size (8))) V;
|
||||||
|
|
||||||
|
void
|
||||||
|
foo (V d, V e)
|
||||||
|
{
|
||||||
|
d <= e;
|
||||||
|
foo ((V){}, (V){});
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user