diff options
author | Nathan Froyd <froydnj@codesourcery.com> | 2010-05-12 15:29:51 +0000 |
---|---|---|
committer | Nathan Froyd <froydnj@gcc.gnu.org> | 2010-05-12 15:29:51 +0000 |
commit | f88203b0110a3f85a5bf4c908dabe7f698653b67 (patch) | |
tree | 674958f9fa698bfd9971b8e167ef2c2deddadc4d | |
parent | b34fd25c83e4a098405b5d520a260fb3ac32b14e (diff) | |
download | gcc-f88203b0110a3f85a5bf4c908dabe7f698653b67.zip gcc-f88203b0110a3f85a5bf4c908dabe7f698653b67.tar.gz gcc-f88203b0110a3f85a5bf4c908dabe7f698653b67.tar.bz2 |
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
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/tree.c | 35 |
2 files changed, 25 insertions, 17 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c5d8e6d..8276650 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +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. */ |