summaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2012-05-27 16:25:58 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2012-05-27 16:25:58 +0000
commit253cbc5f37c1c0025b02f977d6fbebc304bdc87e (patch)
treee3ab539b1c4e074d9ad83e5c9cb0254a4ff9fe41 /gcc/tree.c
parent1ca8bef0218b120d504b18a983b6da1f37f3acbe (diff)
downloadgcc-253cbc5f37c1c0025b02f977d6fbebc304bdc87e.tar.gz
tree.c (build_constructor): Propagate TREE_SIDE_EFFECTS.
* tree.c (build_constructor): Propagate TREE_SIDE_EFFECTS. testsuite/ * gcc.dg/stmt-expr-4.c: New. From-SVN: r187923
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c15
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;