aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimplify.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2017-01-16 22:35:30 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2017-01-16 22:35:30 +0100
commit98e92fb2104bcee038c0de4a116424b093001ae6 (patch)
treeee97ac356e8734e988a1ffa5b6f8e942425a0f7c /gcc/gimplify.c
parente1bcfb924ae9b6dffd7757a6f1a193793af58c2f (diff)
downloadgcc-98e92fb2104bcee038c0de4a116424b093001ae6.zip
gcc-98e92fb2104bcee038c0de4a116424b093001ae6.tar.gz
gcc-98e92fb2104bcee038c0de4a116424b093001ae6.tar.bz2
re PR middle-end/79089 (error: incorrect sharing of tree nodes)
PR c/79089 * gimplify.c (gimplify_init_constructor): If want_value and object == lhs, unshare lhs to avoid invalid tree sharing. Formatting fix. * gcc.c-torture/compile/pr79089.c: New test. From-SVN: r244507
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r--gcc/gimplify.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index e1e9ce9e..2777a23 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -4586,8 +4586,8 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_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, gimple_seq *pre_p, gimple_seq *post_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);
}