public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/c++-modules] d: Fix ICE Segmentation fault during RTL pass: expand on armhf/armel/s390x
@ 2020-08-27 18:13 Nathan Sidwell
0 siblings, 0 replies; only message in thread
From: Nathan Sidwell @ 2020-08-27 18:13 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:6bebbc033d8bf2246745ffef7186b0424e08ba6b
commit 6bebbc033d8bf2246745ffef7186b0424e08ba6b
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date: Fri Jul 24 13:49:37 2020 +0200
d: Fix ICE Segmentation fault during RTL pass: expand on armhf/armel/s390x
gcc/d/ChangeLog:
PR d/96301
* decl.cc (DeclVisitor::visit (FuncDeclaration *)): Only return
non-trivial structs by invisible reference.
gcc/testsuite/ChangeLog:
PR d/96301
* gdc.dg/pr96301a.d: New test.
* gdc.dg/pr96301b.d: New test.
* gdc.dg/pr96301c.d: New test.
Diff:
---
gcc/d/decl.cc | 17 +++++++++++------
gcc/testsuite/gdc.dg/pr96301a.d | 31 +++++++++++++++++++++++++++++++
gcc/testsuite/gdc.dg/pr96301b.d | 25 +++++++++++++++++++++++++
gcc/testsuite/gdc.dg/pr96301c.d | 25 +++++++++++++++++++++++++
4 files changed, 92 insertions(+), 6 deletions(-)
diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index 72c8a8cff06..295f780170a 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -958,11 +958,14 @@ public:
{
tree resdecl = DECL_RESULT (fndecl);
- TREE_TYPE (resdecl)
- = build_reference_type (TREE_TYPE (resdecl));
- DECL_BY_REFERENCE (resdecl) = 1;
- TREE_ADDRESSABLE (resdecl) = 0;
- relayout_decl (resdecl);
+ /* Return non-trivial structs by invisible reference. */
+ if (TREE_ADDRESSABLE (TREE_TYPE (resdecl)))
+ {
+ TREE_TYPE (resdecl) = build_reference_type (TREE_TYPE (resdecl));
+ DECL_BY_REFERENCE (resdecl) = 1;
+ TREE_ADDRESSABLE (resdecl) = 0;
+ relayout_decl (resdecl);
+ }
if (d->nrvo_var)
{
@@ -972,7 +975,9 @@ public:
DECL_NAME (resdecl) = DECL_NAME (var);
/* Don't forget that we take its address. */
TREE_ADDRESSABLE (var) = 1;
- resdecl = build_deref (resdecl);
+
+ if (DECL_BY_REFERENCE (resdecl))
+ resdecl = build_deref (resdecl);
SET_DECL_VALUE_EXPR (var, resdecl);
DECL_HAS_VALUE_EXPR_P (var) = 1;
diff --git a/gcc/testsuite/gdc.dg/pr96301a.d b/gcc/testsuite/gdc.dg/pr96301a.d
new file mode 100644
index 00000000000..314904bbd06
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr96301a.d
@@ -0,0 +1,31 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96301
+// { dg-additional-options "-fPIC" { target fpic } }
+// { dg-do compile }
+struct Type
+{
+ size_t length;
+ int* ptr;
+}
+
+class Container
+{
+ Type children;
+
+ void remove(void* data)
+ {
+ Type remove(Type range)
+ {
+ auto result = range;
+ if (result.front)
+ return result;
+ assert(0);
+ }
+ if (data)
+ remove(children);
+ }
+}
+
+int front(Type a)
+{
+ return a.ptr[0];
+}
diff --git a/gcc/testsuite/gdc.dg/pr96301b.d b/gcc/testsuite/gdc.dg/pr96301b.d
new file mode 100644
index 00000000000..3d978beebc8
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr96301b.d
@@ -0,0 +1,25 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96301
+// { dg-additional-options "-fPIC" { target fpic } }
+// { dg-do compile }
+class Container
+{
+ int[100] children;
+
+ void remove(void* data)
+ {
+ int[100] remove(int[100] range)
+ {
+ auto result = range;
+ if (result.front)
+ return result;
+ assert(0);
+ }
+ if (data)
+ remove(children);
+ }
+}
+
+int front(int[100] a)
+{
+ return a.ptr[0];
+}
diff --git a/gcc/testsuite/gdc.dg/pr96301c.d b/gcc/testsuite/gdc.dg/pr96301c.d
new file mode 100644
index 00000000000..c9094625016
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr96301c.d
@@ -0,0 +1,25 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96301
+// { dg-additional-options "-fPIC" { target fpic } }
+// { dg-do compile }
+class Container
+{
+ int[] children;
+
+ void remove(void* data)
+ {
+ int[] remove(int[] range)
+ {
+ auto result = range;
+ if (result.front)
+ return result;
+ assert(0);
+ }
+ if (data)
+ remove(children);
+ }
+}
+
+int front(int[] a)
+{
+ return a.ptr[0];
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-08-27 18:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-27 18:13 [gcc/devel/c++-modules] d: Fix ICE Segmentation fault during RTL pass: expand on armhf/armel/s390x Nathan Sidwell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).