From patchwork Sun Dec 11 17:52:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 32198 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1861797wrr; Sun, 11 Dec 2022 09:54:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf5FE5Ugj49LhxgU2L+wlx2iiM8C/cZE87WS1Ma5q+I18Ge+PGUim7l1Tpx4gwzBYkTdvGQd X-Received: by 2002:a17:906:1f55:b0:7b9:a74b:f15c with SMTP id d21-20020a1709061f5500b007b9a74bf15cmr11419897ejk.50.1670781250951; Sun, 11 Dec 2022 09:54:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670781250; cv=none; d=google.com; s=arc-20160816; b=Y2EDz6LzgqqEa8zlnVjWk0BkUP4s4F1OsXu46OIpLB2U5oEs39Ywp0pecmML/R7T51 V/kqzf2RpjulGWn+98B2l9NKREpu8KTUO/zmt8CFUtkKUX2+m7zVwEQBpUCLtfUQDcoI 4cZJQZNDQeokY5HsqrOsG0wkBUCayLQDNrtxfQDbmEY8La3ThpLJBnSCL6D7lDDe3cu6 SIPtmUnch37fBrNyjA9r9cX6HDB/HkLRiWvTtgHW0w3Ss+ZrwWDJ7r/Xm2O21eoFSJYH K3CmfA58nnsvDhj5SuawitHWTuXNYpReqWKlzorS+/4NdTgj+aWC3tqBIquLaCxt4+jW fDvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=12rsDmblPjIthmlZaG8FXkZOGfBTASlX5UEKdMzCOc4=; b=dRhA9EqJ6vVkAP+Zob2KCLSLBoWxTrC1JilO3WYC1BIQQ8PYCQ7gQB+v/e9ZAesIqm uU7CjncoJxlX1xm1cQyBdR0s2pxSpm+HaAAvkvGXg025PmTeT/Ipd61g0SoRgvSJIjVv 0xDbhzuD5ay+iI6p2mhnQlwev4yNlxVQH9AE5A9sdYDkTvskOcB6U6t8jYpJF0PdUgZ7 6yT1KOgHy//BCbjBGjYgfvurZm1DBRQzMY1TBICfgN/lK7tKw923syhihbkl9AsQSzPB yI7EV39nKSr/5z/L9ImdWjbav8TqDiMEBdm0gk1nwIa5+LNrFcRRgTvV9VhBHzOrSWPF aMFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=N7ZSLqZV; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id qw28-20020a1709066a1c00b007c0e7a8af31si5076886ejc.939.2022.12.11.09.54.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Dec 2022 09:54:10 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=N7ZSLqZV; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0F4F43834E22 for ; Sun, 11 Dec 2022 17:53:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0F4F43834E22 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670781238; bh=12rsDmblPjIthmlZaG8FXkZOGfBTASlX5UEKdMzCOc4=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=N7ZSLqZVXEd/j43WhdT/vA7hnPk+wkY7I1wpojac/kjX7VpraH4jqQkoOLQ1BDU7z V5ZvMwsSHaaKFCJtZipdKhz0lL/TMgWwwwoAfrq3AvAxwzlNvDLJdumENbsyZF1YhH C6H4ZCTBpc0oD5rhlquqHbRyO7x2KqscSQjP/AP8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by sourceware.org (Postfix) with ESMTPS id 94A0D3875B65 for ; Sun, 11 Dec 2022 17:53:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 94A0D3875B65 Received: from smtp1.mailbox.org (smtp1.mailbox.org [10.196.197.1]) (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-102.mailbox.org (Postfix) with ESMTPS id 4NVXRR1L61z9sR9; Sun, 11 Dec 2022 18:53:07 +0100 (CET) To: gcc-patches@gcc.gnu.org Cc: Iain Buclaw Subject: [committed] d: Fix internal compiler error: in visit, at d/imports.cc:72 (PR108050) Date: Sun, 11 Dec 2022 18:52:59 +0100 Message-Id: <20221211175259.2795408-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP, 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751941120988527939?= X-GMAIL-MSGID: =?utf-8?q?1751941120988527939?= Hi, This patch fixes an ICE in the D front-end when importing symbols that have multiple overloads. The visitor for lowering IMPORTED_DECLs did not have an override for dealing with importing OverloadSet symbols. This has now been implemented in the code generator. Bootstrapped and regression tested on x86_64-linux-gnu/-m32/-mx32, committed to mainline, and backported to the release branches for gcc-10, gcc-11, and gcc-12. Regards, Iain. --- PR d/108050 gcc/d/ChangeLog: * decl.cc (DeclVisitor::visit (Import *)): Handle build_import_decl returning a TREE_LIST. * imports.cc (ImportVisitor::visit (OverloadSet *)): New override. gcc/testsuite/ChangeLog: * gdc.dg/imports/pr108050/mod1.d: New. * gdc.dg/imports/pr108050/mod2.d: New. * gdc.dg/imports/pr108050/package.d: New. * gdc.dg/pr108050.d: New test. --- gcc/d/decl.cc | 12 ++++++++++-- gcc/d/imports.cc | 14 ++++++++++++++ gcc/testsuite/gdc.dg/imports/pr108050/mod1.d | 2 ++ gcc/testsuite/gdc.dg/imports/pr108050/mod2.d | 2 ++ gcc/testsuite/gdc.dg/imports/pr108050/package.d | 2 ++ gcc/testsuite/gdc.dg/pr108050.d | 4 ++++ 6 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gdc.dg/imports/pr108050/mod1.d create mode 100644 gcc/testsuite/gdc.dg/imports/pr108050/mod2.d create mode 100644 gcc/testsuite/gdc.dg/imports/pr108050/package.d create mode 100644 gcc/testsuite/gdc.dg/pr108050.d diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc index dcfca648e44..bed16323fec 100644 --- a/gcc/d/decl.cc +++ b/gcc/d/decl.cc @@ -198,8 +198,16 @@ public: tree name = (alias != NULL) ? get_identifier (alias->toChars ()) : NULL_TREE; - debug_hooks->imported_module_or_decl (decl, name, context, - false, false); + if (TREE_CODE (decl) != TREE_LIST) + debug_hooks->imported_module_or_decl (decl, name, context, + false, false); + else + { + /* Overload sets return a list of imported decls. */ + for (; decl != NULL_TREE; decl = TREE_CHAIN (decl)) + debug_hooks->imported_module_or_decl (TREE_VALUE (decl), name, + context, false, false); + } } } else diff --git a/gcc/d/imports.cc b/gcc/d/imports.cc index 133d93d4961..2d331f46c35 100644 --- a/gcc/d/imports.cc +++ b/gcc/d/imports.cc @@ -160,6 +160,20 @@ public: d->aliassym->accept (this); } + /* Build IMPORTED_DECLs for all overloads in a set. */ + void visit (OverloadSet *d) final override + { + vec *tset = NULL; + + vec_alloc (tset, d->a.length); + + for (size_t i = 0; i < d->a.length; i++) + vec_safe_push (tset, build_import_decl (d->a[i])); + + this->result_ = build_tree_list_vec (tset); + tset->truncate (0); + } + /* Function aliases are the same as alias symbols. */ void visit (FuncAliasDeclaration *d) final override { diff --git a/gcc/testsuite/gdc.dg/imports/pr108050/mod1.d b/gcc/testsuite/gdc.dg/imports/pr108050/mod1.d new file mode 100644 index 00000000000..f27a13dc051 --- /dev/null +++ b/gcc/testsuite/gdc.dg/imports/pr108050/mod1.d @@ -0,0 +1,2 @@ +module imports.pr108050.mod1; +string[] split() { return null; } diff --git a/gcc/testsuite/gdc.dg/imports/pr108050/mod2.d b/gcc/testsuite/gdc.dg/imports/pr108050/mod2.d new file mode 100644 index 00000000000..29d8aa8f53e --- /dev/null +++ b/gcc/testsuite/gdc.dg/imports/pr108050/mod2.d @@ -0,0 +1,2 @@ +module imports.pr108050.mod2; +string[] split() { return null; } diff --git a/gcc/testsuite/gdc.dg/imports/pr108050/package.d b/gcc/testsuite/gdc.dg/imports/pr108050/package.d new file mode 100644 index 00000000000..b8b03b832af --- /dev/null +++ b/gcc/testsuite/gdc.dg/imports/pr108050/package.d @@ -0,0 +1,2 @@ +module imports.pr108050; +public import imports.pr108050.mod1, imports.pr108050.mod2; diff --git a/gcc/testsuite/gdc.dg/pr108050.d b/gcc/testsuite/gdc.dg/pr108050.d new file mode 100644 index 00000000000..69134e73137 --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr108050.d @@ -0,0 +1,4 @@ +// { dg-do compile } +// { dg-additional-sources "imports/pr108050/package.d imports/pr108050/mod1.d imports/pr108050/mod2.d" } +// { dg-options "-g" } +import imports.pr108050 : split;