From: froydnj Date: Wed, 12 May 2010 15:29:51 +0000 (+0000) Subject: * tree.c (build_constructor): Compute TREE_CONSTANT for the X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ce9d9df2f188cd5a7f61f4398a5850bbc5fdba3;p=thirdparty%2Fgcc.git * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159325 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c5d8e6d966ba..8276650f2def 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2010-05-12 Nathan Froyd + + * 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 * cgraph.h (struct varpool_node): Add aux. diff --git a/gcc/tree.c b/gcc/tree.c index c45e807b43d9..934536f24793 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -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. */