diff options
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 35 |
1 files changed, 18 insertions, 17 deletions
@@ -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. */ |