diff options
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/gcc/tree.c b/gcc/tree.c index de4a1c04202..e5c19bccabf 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -1416,17 +1416,24 @@ build_constructor (tree type, VEC(constructor_elt,gc) *vals) unsigned int i; constructor_elt *elt; bool constant_p = true; + bool side_effects_p = false; TREE_TYPE (c) = type; CONSTRUCTOR_ELTS (c) = vals; FOR_EACH_VEC_ELT (constructor_elt, vals, i, elt) - if (!TREE_CONSTANT (elt->value)) - { + { + /* Mostly ctors will have elts that don't have side-effects, so + the usual case is to scan all the elements. Hence a single + loop for both const and side effects, rather than one loop + each (with early outs). */ + if (!TREE_CONSTANT (elt->value)) constant_p = false; - break; - } + if (TREE_SIDE_EFFECTS (elt->value)) + side_effects_p = true; + } + TREE_SIDE_EFFECTS (c) = side_effects_p; TREE_CONSTANT (c) = constant_p; return c; |