@@ -4586,8 +4586,8 @@ gimplify_init_constructor (tree *expr_p,
}
object = TREE_OPERAND (*expr_p, 0);
- ctor = TREE_OPERAND (*expr_p, 1) =
- optimize_compound_literals_in_ctor (TREE_OPERAND (*expr_p, 1));
+ ctor = TREE_OPERAND (*expr_p, 1)
+ = optimize_compound_literals_in_ctor (TREE_OPERAND (*expr_p, 1));
type = TREE_TYPE (ctor);
elts = CONSTRUCTOR_ELTS (ctor);
ret = GS_ALL_DONE;
@@ -4911,6 +4911,8 @@ gimplify_init_constructor (tree *expr_p,
{
tree lhs = TREE_OPERAND (*expr_p, 0);
tree rhs = TREE_OPERAND (*expr_p, 1);
+ if (want_value && object == lhs)
+ lhs = unshare_expr (lhs);
gassign *init = gimple_build_assign (lhs, rhs);
gimplify_seq_add_stmt (pre_p, init);
}
@@ -0,0 +1,12 @@
+/* PR c/79089 */
+
+struct S { int b; };
+struct T { struct S c; } a;
+int d;
+struct S e;
+
+void
+foo ()
+{
+ e = ({ d++; a.c = (struct S) {}; });
+}