re PR tree-optimization/19108 (ICE initializing arrays)

PR tree-opt/19108
        * tree-sra.c (generate_element_init_1): Handle RANGE_EXPR.

From-SVN: r97211
This commit is contained in:
Richard Henderson 2005-03-29 14:43:48 -08:00 committed by Richard Henderson
parent c5c713192a
commit 0e2ea9b837
3 changed files with 49 additions and 4 deletions

View file

@ -1,3 +1,8 @@
2005-03-29 Richard Henderson <rth@redhat.com>
PR tree-opt/19108
* tree-sra.c (generate_element_init_1): Handle RANGE_EXPR.
2005-03-29 Kazu Hirata <kazu@cs.umass.edu>
* builtin-types.def, c-convert.c, c-format.c, ddg.c, debug.c,

View file

@ -0,0 +1,19 @@
// PR tree-optimization/19108
// This used to abort due to not handing RANGE_EXPR in SRA.
// { dg-do compile }
// { dg-options "-O" }
struct A
{
int i[6];
A () : i() {}
};
struct B
{
A a;
B(const A& x) : a(x) {}
};
B b=A();

View file

@ -1639,10 +1639,31 @@ generate_element_init_1 (struct sra_elt *elt, tree init, tree *list_p)
case CONSTRUCTOR:
for (t = CONSTRUCTOR_ELTS (init); t ; t = TREE_CHAIN (t))
{
sub = lookup_element (elt, TREE_PURPOSE (t), NULL, NO_INSERT);
if (sub == NULL)
continue;
result &= generate_element_init_1 (sub, TREE_VALUE (t), list_p);
tree purpose = TREE_PURPOSE (t);
tree value = TREE_VALUE (t);
if (TREE_CODE (purpose) == RANGE_EXPR)
{
tree lower = TREE_OPERAND (purpose, 0);
tree upper = TREE_OPERAND (purpose, 1);
while (1)
{
sub = lookup_element (elt, lower, NULL, NO_INSERT);
if (sub != NULL)
result &= generate_element_init_1 (sub, value, list_p);
if (tree_int_cst_equal (lower, upper))
break;
lower = int_const_binop (PLUS_EXPR, lower,
integer_one_node, true);
}
}
else
{
sub = lookup_element (elt, purpose, NULL, NO_INSERT);
if (sub != NULL)
result &= generate_element_init_1 (sub, value, list_p);
}
}
break;