From 884efbd523b7191edd7763ae8bba8afc96e3c238 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Sat, 10 Aug 2019 14:11:49 +0000 Subject: [PATCH] d: Fix internal compiler error: in add_expr, at tree.c:7794 gcc/d/ChangeLog: PR d/91238 * d-codegen.cc (build_address): If taking the address of a CALL_EXPR, wrap it in a TARGET_EXPR. gcc/testsuite/ChangeLog: PR d/91238 * gdc.dg/pr91238.d: New test. From-SVN: r274253 --- gcc/d/ChangeLog | 6 ++++++ gcc/d/d-codegen.cc | 8 +++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gdc.dg/pr91238.d | 18 ++++++++++++++++++ 4 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gdc.dg/pr91238.d diff --git a/gcc/d/ChangeLog b/gcc/d/ChangeLog index b2a94ea033a..04eaccf3fed 100644 --- a/gcc/d/ChangeLog +++ b/gcc/d/ChangeLog @@ -1,3 +1,9 @@ +2019-08-10 Iain Buclaw + + PR d/91238 + * d-codegen.cc (build_address): If taking the address of a CALL_EXPR, + wrap it in a TARGET_EXPR. + 2019-08-10 Iain Buclaw PR d/90893 diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc index 1971064e334..cf50693b2f5 100644 --- a/gcc/d/d-codegen.cc +++ b/gcc/d/d-codegen.cc @@ -651,9 +651,11 @@ build_address (tree exp) if (TREE_CODE (exp) == CONST_DECL) exp = DECL_INITIAL (exp); - /* Some expression lowering may request an address of a compile-time constant. - Make sure it is assigned to a location we can reference. */ - if (CONSTANT_CLASS_P (exp) && TREE_CODE (exp) != STRING_CST) + /* Some expression lowering may request an address of a compile-time constant, + or other non-lvalue expression. Make sure it is assigned to a location we + can reference. */ + if ((CONSTANT_CLASS_P (exp) && TREE_CODE (exp) != STRING_CST) + || TREE_CODE (exp) == CALL_EXPR) exp = force_target_expr (exp); d_mark_addressable (exp); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 17387f6a7bc..ed12eadfd16 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-08-10 Iain Buclaw + + PR d/91238 + * gdc.dg/pr91238.d: New test. + 2019-08-10 Jakub Jelinek * c-c++-common/gomp/declare-target-2.c: Don't expect error for diff --git a/gcc/testsuite/gdc.dg/pr91238.d b/gcc/testsuite/gdc.dg/pr91238.d new file mode 100644 index 00000000000..26efb906212 --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr91238.d @@ -0,0 +1,18 @@ +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91238 +// { dg-do compile } + +alias T = const(char)*; + +T name() +{ + return ""; +} + +void collect(ref T) +{ +} + +void configure(T[T] targets) +{ + collect(targets[name]); +} -- 2.30.2