From 40af8b2eff82f28d83b2a5fe153cbc53af665956 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Fri, 4 Sep 2020 22:54:22 +0200 Subject: [PATCH] d: Fix ICE in create_tmp_var, at gimple-expr.c:482 Array concatenate expressions were creating more SAVE_EXPRs than what was necessary. The internal error itself was the result of a forced temporary being made on a TREE_ADDRESSABLE type. gcc/d/ChangeLog: PR d/96924 * expr.cc (ExprVisitor::visit (CatAssignExp *)): Don't force temporaries needlessly. gcc/testsuite/ChangeLog: PR d/96924 * gdc.dg/pr96924.d: New test. (cherry picked from commit 52908b8de15a1c762a73063f1162bcedfcc993b4) --- gcc/d/expr.cc | 3 --- gcc/testsuite/gdc.dg/pr96924.d | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gdc.dg/pr96924.d diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc index d1e71f987f7e..9191d3a9510c 100644 --- a/gcc/d/expr.cc +++ b/gcc/d/expr.cc @@ -875,7 +875,6 @@ public: tree offexp = d_array_length (result); offexp = build2 (MINUS_EXPR, TREE_TYPE (offexp), offexp, size_one_node); - offexp = d_save_expr (offexp); tree ptrexp = d_array_ptr (result); ptrexp = void_okay_p (ptrexp); @@ -885,9 +884,7 @@ public: tree t2 = build_expr (e->e2); tree expr = stabilize_expr (&t2); - t2 = d_save_expr (t2); result = modify_expr (build_deref (ptrexp), t2); - result = compound_expr (t2, result); this->result_ = compound_expr (expr, result); } diff --git a/gcc/testsuite/gdc.dg/pr96924.d b/gcc/testsuite/gdc.dg/pr96924.d new file mode 100644 index 000000000000..25d9a566fbee --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr96924.d @@ -0,0 +1,14 @@ +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96924 +// { dg-do compile } + +struct Memo +{ + string source; + this(this); +} + +void compile(string src, size_t end) +{ + Memo[] stack; + stack ~= Memo(src[end .. $]); +} -- 2.43.5