aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimplify.c
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@gcc.gnu.org>2015-04-17 12:14:24 +0000
committerPatrick Palka <ppalka@gcc.gnu.org>2015-04-17 12:14:24 +0000
commit2234a9cb75c9f2ba6d6b944a93c673e5b3fc004a (patch)
treee673e0b8a136f5b01ca1c70882bc13acd7a0cfd5 /gcc/gimplify.c
parent3f6a2f9e08e49561d682d334d383ec1be9d4dc92 (diff)
downloadgcc-2234a9cb75c9f2ba6d6b944a93c673e5b3fc004a.zip
gcc-2234a9cb75c9f2ba6d6b944a93c673e5b3fc004a.tar.gz
gcc-2234a9cb75c9f2ba6d6b944a93c673e5b3fc004a.tar.bz2
re PR c++/64527 (Constructor for empty struct not called in some situations)
Fix PR c++/64527 gcc/ PR c++/64527 * gimplify.c (gimplify_init_constructor): Always emit a side-effecting constructor. gcc/testsuite/ PR c++/64527 * g++.dg/init/pr64527.C: New test. From-SVN: r222176
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r--gcc/gimplify.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 0394543..c701ef3 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -3994,6 +3994,9 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
pre_p, post_p, &preeval_data);
}
+ bool ctor_has_side_effects_p
+ = TREE_SIDE_EFFECTS (TREE_OPERAND (*expr_p, 1));
+
if (cleared)
{
/* Zap the CONSTRUCTOR element list, which simplifies this case.
@@ -4006,9 +4009,11 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
}
/* If we have not block cleared the object, or if there are nonzero
- elements in the constructor, add assignments to the individual
- scalar fields of the object. */
- if (!cleared || num_nonzero_elements > 0)
+ elements in the constructor, or if the constructor has side effects,
+ add assignments to the individual scalar fields of the object. */
+ if (!cleared
+ || num_nonzero_elements > 0
+ || ctor_has_side_effects_p)
gimplify_init_ctor_eval (object, elts, pre_p, cleared);
*expr_p = NULL_TREE;