]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
d: Fix ICE in in add_stack_var, at cfgexpand.cc:476
authorIain Buclaw <ibuclaw@gdcproject.org>
Mon, 8 Aug 2022 13:17:47 +0000 (15:17 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Mon, 8 Aug 2022 18:29:04 +0000 (20:29 +0200)
The type that triggers the ICE never got completed by the semantic
analysis pass.  Checking for size forces it to be done, or issue a
compile-time error.

PR d/106555

gcc/d/ChangeLog:

* d-target.cc (Target::isReturnOnStack): Check for return type size.

gcc/testsuite/ChangeLog:

* gdc.dg/imports/pr106555.d: New test.
* gdc.dg/pr106555.d: New test.

(cherry picked from commit 4b0253b019943abf2cc5f4db0b7ed67caedffe4a)

gcc/d/d-target.cc
gcc/testsuite/gdc.dg/imports/pr106555.d [new file with mode: 0644]
gcc/testsuite/gdc.dg/pr106555.d [new file with mode: 0644]

index 610be74ad4876c17c5b9930e3e53dc298ff79f9e..d4350e593e4f32f12084f7dc78a7e66c848ddb6b 100644 (file)
@@ -464,6 +464,8 @@ Target::isReturnOnStack (TypeFunction *tf, bool)
     return false;
 
   Type *tn = tf->next->toBasetype ();
+  if (tn->size () == SIZE_INVALID)
+    return false;
 
   return (tn->ty == TY::Tstruct || tn->ty == TY::Tsarray);
 }
diff --git a/gcc/testsuite/gdc.dg/imports/pr106555.d b/gcc/testsuite/gdc.dg/imports/pr106555.d
new file mode 100644 (file)
index 0000000..0d3ab6b
--- /dev/null
@@ -0,0 +1,10 @@
+module imports.pr106555;
+struct S106555
+{
+    int[] f106555;
+    int max106555;
+    this(int)
+    {
+        f106555.length = max106555;
+    }
+}
diff --git a/gcc/testsuite/gdc.dg/pr106555.d b/gcc/testsuite/gdc.dg/pr106555.d
new file mode 100644 (file)
index 0000000..7b40f3c
--- /dev/null
@@ -0,0 +1,4 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106555
+// { dg-do compile }
+// { dg-additional-options "-O2" }
+// { dg-additional-sources "imports/pr106555.d" }