Commit f88203b0 by Nathan Froyd Committed by Nathan Froyd

tree.c (build_constructor): Compute TREE_CONSTANT for the resultant constructor.

	* tree.c (build_constructor): Compute TREE_CONSTANT for the
	resultant constructor.
	(build_constructor_single): Don't set TREE_CONSTANT.
	(build_constructor_from_list): Don't compute TREE_CONSTANT.

From-SVN: r159325
parent b34fd25c
2010-05-12 Nathan Froyd <froydnj@codesourcery.com>
* tree.c (build_constructor): Compute TREE_CONSTANT for the
resultant constructor.
(build_constructor_single): Don't set TREE_CONSTANT.
(build_constructor_from_list): Don't compute TREE_CONSTANT.
2010-05-12 Jan Hubicka <jh@suse.cz> 2010-05-12 Jan Hubicka <jh@suse.cz>
* cgraph.h (struct varpool_node): Add aux. * cgraph.h (struct varpool_node): Add aux.
......
...@@ -1332,8 +1332,22 @@ tree ...@@ -1332,8 +1332,22 @@ tree
build_constructor (tree type, VEC(constructor_elt,gc) *vals) build_constructor (tree type, VEC(constructor_elt,gc) *vals)
{ {
tree c = make_node (CONSTRUCTOR); tree c = make_node (CONSTRUCTOR);
unsigned int i;
constructor_elt *elt;
bool constant_p = true;
TREE_TYPE (c) = type; TREE_TYPE (c) = type;
CONSTRUCTOR_ELTS (c) = vals; CONSTRUCTOR_ELTS (c) = vals;
for (i = 0; VEC_iterate (constructor_elt, vals, i, elt); i++)
if (!TREE_CONSTANT (elt->value))
{
constant_p = false;
break;
}
TREE_CONSTANT (c) = constant_p;
return c; return c;
} }
...@@ -1344,16 +1358,13 @@ build_constructor_single (tree type, tree index, tree value) ...@@ -1344,16 +1358,13 @@ build_constructor_single (tree type, tree index, tree value)
{ {
VEC(constructor_elt,gc) *v; VEC(constructor_elt,gc) *v;
constructor_elt *elt; constructor_elt *elt;
tree t;
v = VEC_alloc (constructor_elt, gc, 1); v = VEC_alloc (constructor_elt, gc, 1);
elt = VEC_quick_push (constructor_elt, v, NULL); elt = VEC_quick_push (constructor_elt, v, NULL);
elt->index = index; elt->index = index;
elt->value = value; elt->value = value;
t = build_constructor (type, v); return build_constructor (type, v);
TREE_CONSTANT (t) = TREE_CONSTANT (value);
return t;
} }
...@@ -1362,27 +1373,17 @@ build_constructor_single (tree type, tree index, tree value) ...@@ -1362,27 +1373,17 @@ build_constructor_single (tree type, tree index, tree value)
tree tree
build_constructor_from_list (tree type, tree vals) build_constructor_from_list (tree type, tree vals)
{ {
tree t, val; tree t;
VEC(constructor_elt,gc) *v = NULL; VEC(constructor_elt,gc) *v = NULL;
bool constant_p = true;
if (vals) if (vals)
{ {
v = VEC_alloc (constructor_elt, gc, list_length (vals)); v = VEC_alloc (constructor_elt, gc, list_length (vals));
for (t = vals; t; t = TREE_CHAIN (t)) for (t = vals; t; t = TREE_CHAIN (t))
{ CONSTRUCTOR_APPEND_ELT (v, TREE_PURPOSE (t), TREE_VALUE (t));
constructor_elt *elt = VEC_quick_push (constructor_elt, v, NULL);
val = TREE_VALUE (t);
elt->index = TREE_PURPOSE (t);
elt->value = val;
if (!TREE_CONSTANT (val))
constant_p = false;
}
} }
t = build_constructor (type, v); return build_constructor (type, v);
TREE_CONSTANT (t) = constant_p;
return t;
} }
/* Return a new FIXED_CST node whose type is TYPE and value is F. */ /* Return a new FIXED_CST node whose type is TYPE and value is F. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment