From patchwork Mon Aug 15 19:46:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 536 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:38f:b0:2d5:3c95:9e21 with SMTP id 15csp1558673pxh; Mon, 15 Aug 2022 12:47:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR4Y2fFTpylBRvkCak51bZQ7yOhkEwFHOuqJS3Dn5U89C3JM5tQ3wVqBK//sYtaOqKHJmPHL X-Received: by 2002:aa7:d6cd:0:b0:43d:4ab8:87b8 with SMTP id x13-20020aa7d6cd000000b0043d4ab887b8mr15895404edr.412.1660592842658; Mon, 15 Aug 2022 12:47:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660592842; cv=none; d=google.com; s=arc-20160816; b=WlqA/ZBkJlTt+NeJK2SWlRKc9niYExrVEZsd1MA0/k63y8P0a6dk66yfNpv7C3DF5r Wfnocv76ZzodmqhovNJLRScbatkrGPgTqCdi1USlhkB9935eNGK/pOoHJ8bF72NSQfA2 75azIdRwXKPpem0u17VFApbOMBS8Fhs6n/AIcKehbYjLYXQzMNxX5Wkpvn19i+yl0Mqi uR/AmR4u0HF0V5CKJc3O9mIxKG7QhpD/6ohiy7WgvB2SR2iJDmjvi2BdYTq7SGK1PQnA 77dKeeV1Xlhhn8Fg8tSbYLdoxvAOHo6Boj/6Urzjq5hMtxOHENDv+lx0Ac1IQGkaNn1M Jp2g== 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:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=KpTSuzxOe4hvjpIQP9aQLhDIbUEdkmuwNpnMQZGcr+I=; b=d6sQV7LoJ7IYaI2yFE9C841HkWINyMmVtgOzHhY1bIPfQJ2bvrJkFcgQX7vI9o3qzF OJthjMZJw3zQIAGMLNAC3LNDVM1qWsBxV1rkfjPMnCZ8v1bIi8eAO2EwtUA+AHrWjXp2 yG0U+JzG0iapVO5kiO3WXaHR2UlWwAHd1UDHS8cxMdqjpM71WAi6IzpjG2N8Rulhn1xo bAps7cGAutOc9v1j0BHFShi6o0hGbGDwZymwkGZWZ/oA7wghAgy2h723BAumvvt3Q3XF tpC8l73wi4LdsNnrWDBw6lTdGU4RD2k3l8pVQkrA+p4Mgtxdvf6w1uZb2m9lNS385xrQ bbdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Ggcigdcm; 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 um2-20020a170906cf8200b0072b5adee783si7342853ejb.523.2022.08.15.12.47.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Aug 2022 12:47:22 -0700 (PDT) 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=Ggcigdcm; 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 855293858427 for ; Mon, 15 Aug 2022 19:47:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 855293858427 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660592841; bh=KpTSuzxOe4hvjpIQP9aQLhDIbUEdkmuwNpnMQZGcr+I=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=GgcigdcmFfK2afEJCX4Au/u4i+0rQioyOmyjQFjgQoy6M3m5g0PITqQyMotcF634N 5jd9kkKvvPzh/ERdYXuLHvezrVn626X7a+stA0gA7QdDMzZ+i+rZVmGU59gWhI1dQ9 vsLFy7+7iGY5n2ZXCaqd4owZ/D84NsoubG2aVabU= 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 0026F3858C2F for ; Mon, 15 Aug 2022 19:46:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0026F3858C2F Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (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 4M64Xj5pXNz9sVN; Mon, 15 Aug 2022 21:46:29 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [committed] d: Build internal TypeInfo types when module name is "object" Date: Mon, 15 Aug 2022 21:46:28 +0200 Message-Id: <20220815194628.2361568-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, T_SCC_BODY_TEXT_LINE 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?1741257800199149716?= X-GMAIL-MSGID: =?utf-8?q?1741257800199149716?= Hi, This patch is a fix-up for a previous change in r13-1070. If for whatever reason the module declaration doesn't exist in the object file, ensure that the internal definitions for TypeInfo and TypeInfo_Class are still created, otherwise an ICE could occur later if they are required for a run-time helper call. Regression tested on x86_64-linux-gnu, and committed to mainline. Regards, Iain. --- gcc/d/ChangeLog: * d-compiler.cc (Compiler::onParseModule): Call create_tinfo_types when module name is object. * typeinfo.cc (create_tinfo_types): Add guard for multiple invocations. --- gcc/d/d-compiler.cc | 11 +++++++++-- gcc/d/typeinfo.cc | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/gcc/d/d-compiler.cc b/gcc/d/d-compiler.cc index ada9721541b..ef19df12437 100644 --- a/gcc/d/d-compiler.cc +++ b/gcc/d/d-compiler.cc @@ -130,8 +130,7 @@ Compiler::onParseModule (Module *m) { if (md->packages.length == 0) { - Identifier *id = (md && md->id) ? md->id : m->ident; - if (!strcmp (id->toChars (), "object")) + if (!strcmp (md->id->toChars (), "object")) { create_tinfo_types (m); return; @@ -147,6 +146,14 @@ Compiler::onParseModule (Module *m) } } } + else if (m->ident) + { + if (!strcmp (m->ident->toChars (), "object")) + { + create_tinfo_types (m); + return; + } + } if (!flag_no_builtin) d_add_builtin_module (m); diff --git a/gcc/d/typeinfo.cc b/gcc/d/typeinfo.cc index d1f0d59952f..3577f669ed1 100644 --- a/gcc/d/typeinfo.cc +++ b/gcc/d/typeinfo.cc @@ -244,6 +244,10 @@ make_frontend_typeinfo (Identifier *ident, ClassDeclaration *base = NULL) void create_tinfo_types (Module *mod) { + /* Already generated internal types for the object module. */ + if (object_module != NULL) + return; + /* Build the internal TypeInfo and ClassInfo types. See TypeInfoVisitor for documentation of field layout. */ make_internal_typeinfo (TK_TYPEINFO_TYPE, Identifier::idPool ("TypeInfo"),