]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
d: Build internal TypeInfo types when module name is "object"
authorIain Buclaw <ibuclaw@gdcproject.org>
Mon, 15 Aug 2022 11:43:29 +0000 (13:43 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Mon, 15 Aug 2022 19:35:09 +0000 (21:35 +0200)
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.

gcc/d/d-compiler.cc
gcc/d/typeinfo.cc

index ada9721541bd2402d40c28c02a7c78f00285c567..ef19df12437a4a4ddfc80d261f2e8045db96db2b 100644 (file)
@@ -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);
index d1f0d59952f99d91464f4fa86e8e4abd3368df59..3577f669ed18d551b3087f581801372f4c8aa779 100644 (file)
@@ -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"),