diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2021-06-04 19:38:26 +0200 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2021-06-04 20:45:01 +0200 |
commit | df3fbd5957f12927a459a2686f4eee55f66ec2f4 (patch) | |
tree | c9387e7a394e7e91adcaf72aa799f4a48f03e88b /gcc/d/expr.cc | |
parent | 6f8c9691495ad5a307db98dc19c3296ee4e6de64 (diff) | |
download | gcc-df3fbd5957f12927a459a2686f4eee55f66ec2f4.zip gcc-df3fbd5957f12927a459a2686f4eee55f66ec2f4.tar.gz gcc-df3fbd5957f12927a459a2686f4eee55f66ec2f4.tar.bz2 |
d: Fix ICE in gimplify_var_or_parm_decl, at gimplify.c:2755 (PR100882)
Constructor calls for temporaries were reusing the TARGET_EXPR_SLOT of a
TARGET_EXPR for an assignment, which later got passed to `build_assign',
which stripped away the outer TARGET_EXPR, leaving a reference to a lone
temporary with no declaration.
This stripping away of the TARGET_EXPR also discarded any cleanups that
may have been assigned to the expression as well.
So now the reuse of TARGET_EXPR_SLOT has been removed, and
`build_assign' now constructs assignments inside the TARGET_EXPR_INITIAL
slot. This has also been extended to `return_expr', to deal with
possibility of a TARGET_EXPR being returned.
gcc/d/ChangeLog:
PR d/100882
* d-codegen.cc (build_assign): Construct initializations inside
TARGET_EXPR_INITIAL.
(compound_expr): Remove intermediate expressions that have no
side-effects.
(return_expr): Construct returns inside TARGET_EXPR_INITIAL.
* expr.cc (ExprVisitor::visit (CallExp *)): Remove useless assignment
to TARGET_EXPR_SLOT.
gcc/testsuite/ChangeLog:
PR d/100882
* gdc.dg/pr100882a.d: New test.
* gdc.dg/pr100882b.d: New test.
* gdc.dg/pr100882c.d: New test.
* gdc.dg/torture/pr100882.d: New test.
Diffstat (limited to 'gcc/d/expr.cc')
-rw-r--r-- | gcc/d/expr.cc | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc index aad7cbb..e76cae9 100644 --- a/gcc/d/expr.cc +++ b/gcc/d/expr.cc @@ -1894,15 +1894,10 @@ public: exp = d_convert (build_ctype (e->type), exp); /* If this call was found to be a constructor for a temporary with a - cleanup, then move the call inside the TARGET_EXPR. The original - initializer is turned into an assignment, to keep its side effect. */ + cleanup, then move the call inside the TARGET_EXPR. */ if (cleanup != NULL_TREE) { tree init = TARGET_EXPR_INITIAL (cleanup); - tree slot = TARGET_EXPR_SLOT (cleanup); - d_mark_addressable (slot); - init = build_assign (INIT_EXPR, slot, init); - TARGET_EXPR_INITIAL (cleanup) = compound_expr (init, exp); exp = cleanup; } |