aboutsummaryrefslogtreecommitdiff
path: root/gcc/d/d-convert.cc
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2020-05-06 23:34:11 +0200
committerIain Buclaw <ibuclaw@gdcproject.org>2020-05-06 23:56:24 +0200
commit0af711e1914ab6d88538f1fcf0146757b5608b1d (patch)
treedf70951ad00460851908ea8166de5c247d59cc32 /gcc/d/d-convert.cc
parent46fcef99f49cc2d9f28d98f8ecdbf8263e9e0a87 (diff)
downloadgcc-0af711e1914ab6d88538f1fcf0146757b5608b1d.zip
gcc-0af711e1914ab6d88538f1fcf0146757b5608b1d.tar.gz
gcc-0af711e1914ab6d88538f1fcf0146757b5608b1d.tar.bz2
d: Fix ICE in verify_gimple_stmt, at tree-cfg.c:4959
Both array concat and array new expressions wrapped any temporaries created into a BIND_EXPR. This does not work if an expression used to construct the result requires scope destruction, which is represented by a TARGET_EXPR with a clean-up, and a CLEANUP_POINT_EXPR at the location where the temporaries logically go out of scope. The reason for this not working is because the lowering of cleanup point expressions does not traverse inside BIND_EXPRs to expand any gimple cleanup expressions within. The use of creating BIND_EXPR has been removed at both locations, and replaced with a normal temporary variable that has initialization delayed until its address is taken. gcc/d/ChangeLog: PR d/94970 * d-codegen.cc (force_target_expr): Move create_temporary_var implementation inline here. (create_temporary_var): Remove. (maybe_temporary_var): Remove. (bind_expr): Remove. * d-convert.cc (d_array_convert): Use build_local_temp to generate temporaries, and generate its assignment. * d-tree.h (create_temporary_var): Remove. (maybe_temporary_var): Remove. (d_array_convert): Remove vars argument. * expr.cc (ExprVisitor::visit (CatExp *)): Use build_local_temp to generate temporaries, don't wrap them in a BIND_EXPR. (ExprVisitor::visit (NewExp *)): Likewise. gcc/testsuite/ChangeLog: PR d/94970 * gdc.dg/pr94970.d: New test.
Diffstat (limited to 'gcc/d/d-convert.cc')
-rw-r--r--gcc/d/d-convert.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/gcc/d/d-convert.cc b/gcc/d/d-convert.cc
index e2921ec..f93405e 100644
--- a/gcc/d/d-convert.cc
+++ b/gcc/d/d-convert.cc
@@ -774,21 +774,23 @@ d_array_convert (Expression *exp)
/* Convert EXP to a dynamic array, where ETYPE is the element type.
Similar to above, except that EXP is allowed to be an element of an array.
- Temporary variables that need some kind of BIND_EXPR are pushed to VARS. */
+ Temporary variables are created inline if EXP is not an lvalue. */
tree
-d_array_convert (Type *etype, Expression *exp, vec<tree, va_gc> **vars)
+d_array_convert (Type *etype, Expression *exp)
{
Type *tb = exp->type->toBasetype ();
if ((tb->ty != Tarray && tb->ty != Tsarray) || same_type_p (tb, etype))
{
/* Convert single element to an array. */
- tree var = NULL_TREE;
- tree expr = maybe_temporary_var (build_expr (exp), &var);
+ tree expr = build_expr (exp);
- if (var != NULL_TREE)
- vec_safe_push (*vars, var);
+ if (!exp->isLvalue ())
+ {
+ tree var = build_local_temp (TREE_TYPE (expr));
+ expr = compound_expr (modify_expr (var, expr), var);
+ }
return d_array_value (build_ctype (exp->type->arrayOf ()),
size_int (1), build_address (expr));