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: 56760 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 BB3033858428 for ; Mon, 15 Aug 2022 19:47:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BB3033858428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660592825; bh=KpTSuzxOe4hvjpIQP9aQLhDIbUEdkmuwNpnMQZGcr+I=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=QLlDsCglZXIhYiLDI4yfTV6h4Yz3/HhaihNy9oxRhMXC+++cYJbkl6/3Q5dFOEG+t OdptQRuP6fwr5g7DviOdn4tuBAee+LJ2MBOYE1goXx2HIs9/aa35pzLkr81fJqMi9C 8qbPsLibhBYqKSGai/+S0snCmZCzGd1ya1uisSKw= 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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"),