From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [IPv6:2001:67c:2050::465:202]) by sourceware.org (Postfix) with ESMTPS id 57CA5393CC3F for ; Fri, 30 Jul 2021 11:01:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 57CA5393CC3F Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (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-202.mailbox.org (Postfix) with ESMTPS id 4Gbkwp3yPVzQk8f; Fri, 30 Jul 2021 13:01:30 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173]) (amavisd-new, port 10030) with ESMTP id vilXRnmibVDP; Fri, 30 Jul 2021 13:01:27 +0200 (CEST) From: Iain Buclaw To: gcc-patches@gcc.gnu.org Subject: [committed 08/12] d: Only handle named enums in enum_initializer_decl Date: Fri, 30 Jul 2021 13:01:07 +0200 Message-Id: <20210730110111.569140-8-ibuclaw@gdcproject.org> In-Reply-To: <20210730110111.569140-1-ibuclaw@gdcproject.org> References: <20210730110111.569140-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: CAAE3183B X-Rspamd-UID: 063f1e X-Spam-Status: No, score=-15.7 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 autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Fri, 30 Jul 2021 11:01:32 -0000 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 | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc index cf61cd49159..0d46ee180e7 100644 --- a/gcc/d/decl.cc +++ b/gcc/d/decl.cc @@ -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); -- 2.30.2