]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
d: Only handle named enums in enum_initializer_decl
authorIain Buclaw <ibuclaw@gdcproject.org>
Mon, 26 Jul 2021 17:10:47 +0000 (19:10 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Fri, 30 Jul 2021 10:51:36 +0000 (12:51 +0200)
Anonymous enums neither generate an initializer nor typeinfo symbol, so
it's safe to assert that all enum declarations passed to this function
always have an identifier.

gcc/d/ChangeLog:

* decl.cc (enum_initializer_decl): Only handle named enums.

gcc/d/decl.cc

index cf61cd49159ac158e0c7a0ed56f44e5350e468f1..0d46ee180e75d52774dbb10d3cac58cc1e573451 100644 (file)
@@ -2218,13 +2218,10 @@ enum_initializer_decl (EnumDeclaration *decl)
   if (decl->sinit)
     return decl->sinit;
 
-  tree type = build_ctype (decl->type);
+  gcc_assert (decl->ident);
 
-  Identifier *ident_save = decl->ident;
-  if (!decl->ident)
-    decl->ident = Identifier::generateId ("__enum");
+  tree type = build_ctype (decl->type);
   tree ident = mangle_internal_decl (decl, "__init", "Z");
-  decl->ident = ident_save;
 
   decl->sinit = declare_extern_var (ident, type);
   DECL_LANG_SPECIFIC (decl->sinit) = build_lang_decl (NULL);