diff options
author | nathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-05-27 16:25:58 +0000 |
---|---|---|
committer | nathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-05-27 16:25:58 +0000 |
commit | b3a0814be6d7f03aa8221c7a2b98bd5017f62275 (patch) | |
tree | e3ab539b1c4e074d9ad83e5c9cb0254a4ff9fe41 /gcc/tree.c | |
parent | 417e3e9f4bd692039da9e122b9117a00567e8a51 (diff) | |
download | gcc-b3a0814be6d7f03aa8221c7a2b98bd5017f62275.tar.gz |
* tree.c (build_constructor): Propagate TREE_SIDE_EFFECTS.
testsuite/
* gcc.dg/stmt-expr-4.c: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@187923 138bc75d-0d04-0410-961f-82ee72b054a4
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; |