From patchwork Mon Aug 8 18:30:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 56599 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4A4BB385703F for ; Mon, 8 Aug 2022 18:31:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4A4BB385703F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1659983470; bh=ZolzvSqlYPv6L44UXan36gtOrF5PpMM7TtjmjcEzV8k=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=JQeFfYFW3AqaM0dFKRr+5AVPGMDAaMSGwZHjqgWlur2NUux7iqGuoDLBx6XC4F5Hh MvqkXqHvOo/Tkq+d1yIDB55yWIOfFzY/p9nMdL81Mqkk5gqZmqz6rPQ4x+sxELgV+s JijHik8swJM4MCz1I261eWr9Jkt0zrJusm4t5vzM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [IPv6:2001:67c:2050:0:465::201]) by sourceware.org (Postfix) with ESMTPS id F2358385700D for ; Mon, 8 Aug 2022 18:30:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F2358385700D Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4M1lBP45Qzz9sTM; Mon, 8 Aug 2022 20:30:37 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [committed] d: Fix ICE in in add_stack_var, at cfgexpand.cc:476 (PR106555) Date: Mon, 8 Aug 2022 20:30:34 +0200 Message-Id: <20220808183034.817887-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi, This patch fixes the ICE reported in PR d/106555. 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. Bootstrapped and regression tested on x86_64-linux-gnu/-m32/-mx32, committed to mainline, and backported to the releases/gcc-12 branch. Regards, Iain. --- 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. --- 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(+) create mode 100644 gcc/testsuite/gdc.dg/imports/pr106555.d create mode 100644 gcc/testsuite/gdc.dg/pr106555.d 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" }