From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1873) id 58AF3385700D; Mon, 8 Aug 2022 18:28:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 58AF3385700D MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Iain Buclaw To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-1992] d: Fix ICE in in add_stack_var, at cfgexpand.cc:476 X-Act-Checkin: gcc X-Git-Author: Iain Buclaw X-Git-Refname: refs/heads/master X-Git-Oldrev: 01b1afdc35c13cbff5cd3d37f9319285ab84b157 X-Git-Newrev: 4b0253b019943abf2cc5f4db0b7ed67caedffe4a Message-Id: <20220808182805.58AF3385700D@sourceware.org> Date: Mon, 8 Aug 2022 18:28:05 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Aug 2022 18:28:05 -0000 https://gcc.gnu.org/g:4b0253b019943abf2cc5f4db0b7ed67caedffe4a commit r13-1992-g4b0253b019943abf2cc5f4db0b7ed67caedffe4a Author: Iain Buclaw Date: Mon Aug 8 15:17:47 2022 +0200 d: Fix ICE in in add_stack_var, at cfgexpand.cc:476 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. Diff: --- gcc/d/d-target.cc | 2 ++ gcc/testsuite/gdc.dg/imports/pr106555.d | 10 ++++++++++ gcc/testsuite/gdc.dg/pr106555.d | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/gcc/d/d-target.cc b/gcc/d/d-target.cc index 610be74ad48..d4350e593e4 100644 --- a/gcc/d/d-target.cc +++ b/gcc/d/d-target.cc @@ -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 index 00000000000..0d3ab6bb747 --- /dev/null +++ b/gcc/testsuite/gdc.dg/imports/pr106555.d @@ -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 index 00000000000..7b40f3c097b --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr106555.d @@ -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" }