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>
* cgraph.h (struct varpool_node): Add aux.
......
......@@ -1332,8 +1332,22 @@ tree
build_constructor (tree type, VEC(constructor_elt,gc) *vals)
{
tree c = make_node (CONSTRUCTOR);
unsigned int i;
constructor_elt *elt;
bool constant_p = true;
TREE_TYPE (c) = type;
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;
}
......@@ -1344,16 +1358,13 @@ build_constructor_single (tree type, tree index, tree value)
{
VEC(constructor_elt,gc) *v;
constructor_elt *elt;
tree t;
v = VEC_alloc (constructor_elt, gc, 1);
elt = VEC_quick_push (constructor_elt, v, NULL);
elt->index = index;
elt->value = value;
t = build_constructor (type, v);
TREE_CONSTANT (t) = TREE_CONSTANT (value);
return t;
return build_constructor (type, v);
}
......@@ -1362,27 +1373,17 @@ build_constructor_single (tree type, tree index, tree value)
tree
build_constructor_from_list (tree type, tree vals)
{
tree t, val;
tree t;
VEC(constructor_elt,gc) *v = NULL;
bool constant_p = true;
if (vals)
{
v = VEC_alloc (constructor_elt, gc, list_length (vals));
for (t = vals; t; t = TREE_CHAIN (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;
}
CONSTRUCTOR_APPEND_ELT (v, TREE_PURPOSE (t), TREE_VALUE (t));
}
t = build_constructor (type, v);
TREE_CONSTANT (t) = constant_p;
return t;
return build_constructor (type, v);
}
/* 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