From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1873) id 9EF383858425; Mon, 15 Aug 2022 19:37:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9EF383858425 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-2056] d: Build internal TypeInfo types when module name is "object" X-Act-Checkin: gcc X-Git-Author: Iain Buclaw X-Git-Refname: refs/heads/master X-Git-Oldrev: 9fb12ee6fb75be4f980a235dc3f28a29ecc80de0 X-Git-Newrev: 250b1fa19d76b3e2f7a175b6b9ee6086fb548bfe Message-Id: <20220815193733.9EF383858425@sourceware.org> Date: Mon, 15 Aug 2022 19:37:33 +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, 15 Aug 2022 19:37:33 -0000 https://gcc.gnu.org/g:250b1fa19d76b3e2f7a175b6b9ee6086fb548bfe commit r13-2056-g250b1fa19d76b3e2f7a175b6b9ee6086fb548bfe Author: Iain Buclaw Date: Mon Aug 15 13:43:29 2022 +0200 d: Build internal TypeInfo types when module name is "object" 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. 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. Diff: --- 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"),