From patchwork Fri Jul 30 11:01:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1511610 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=aiA0D1N0; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gbl2z49v2z9sfG for ; Fri, 30 Jul 2021 21:06:51 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A942D393F832 for ; Fri, 30 Jul 2021 11:06:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A942D393F832 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1627643208; bh=isDfvs9OHaFZkG5ALVOI6s0wjZJzpsnbu/bPR+ZAPrA=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=aiA0D1N0qVEWr2OU6+F3cEACHRNH+FwvJ3yNhv48iK0pz3aGhypSlPnRoBZS0hVVW 5eDic4ZYXVs2wzJ/QS+lF2aqJ8eoSos0EisuwUK8vXR5bHDsC4UbbFnExqYb/8SGli mI3fZEo6OK768MJ2jKQYGPIoQFLlC9scUPI/UDVk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [IPv6:2001:67c:2050::465:101]) by sourceware.org (Postfix) with ESMTPS id 4686F393F82B for ; Fri, 30 Jul 2021 11:01:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4686F393F82B Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (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-101.mailbox.org (Postfix) with ESMTPS id 4Gbkwm27KPzQk3Q; Fri, 30 Jul 2021 13:01:28 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter06.heinlein-hosting.de (spamfilter06.heinlein-hosting.de [80.241.56.125]) (amavisd-new, port 10030) with ESMTP id nYHfPKWRKpXN; Fri, 30 Jul 2021 13:01:25 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [committed 06/12] d: Factor aggregate_initializer_decl to set the sinit for aggregate declarations. Date: Fri, 30 Jul 2021 13:01:05 +0200 Message-Id: <20210730110111.569140-6-ibuclaw@gdcproject.org> In-Reply-To: <20210730110111.569140-1-ibuclaw@gdcproject.org> References: <20210730110111.569140-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 8870B1838 X-Rspamd-UID: 3594b6 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-Patchwork-Original-From: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" The self-hosted implementation of the D front-end changes the type of `sinit' to a void pointer, which requires an explicit cast to `tree'. gcc/d/ChangeLog: * decl.cc (DeclVisitor::visit (StructDeclaration *)): Don't use sinit for declaration directly. (DeclVisitor::visit (ClassDeclaration *)): Likewise. (aggregate_initializer_decl): Likewise. Set sinit after creating. --- gcc/d/decl.cc | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc index 7d1378255bd..59991c3c255 100644 --- a/gcc/d/decl.cc +++ b/gcc/d/decl.cc @@ -386,9 +386,9 @@ public: create_typeinfo (d->type, NULL); /* Generate static initializer. */ - d->sinit = aggregate_initializer_decl (d); - DECL_INITIAL (d->sinit) = layout_struct_initializer (d); - d_finish_decl (d->sinit); + tree sinit = aggregate_initializer_decl (d); + DECL_INITIAL (sinit) = layout_struct_initializer (d); + d_finish_decl (sinit); /* Put out the members. There might be static constructors in the members list, and they cannot be put in separate object files. */ @@ -496,11 +496,11 @@ public: /* Generate C symbols. */ d->csym = get_classinfo_decl (d); d->vtblsym = get_vtable_decl (d); - d->sinit = aggregate_initializer_decl (d); + tree sinit = aggregate_initializer_decl (d); /* Generate static initializer. */ - DECL_INITIAL (d->sinit) = layout_class_initializer (d); - d_finish_decl (d->sinit); + DECL_INITIAL (sinit) = layout_class_initializer (d); + d_finish_decl (sinit); /* Put out the TypeInfo. */ if (have_typeinfo_p (Type::dtypeinfo)) @@ -2151,7 +2151,7 @@ tree aggregate_initializer_decl (AggregateDeclaration *decl) { if (decl->sinit) - return decl->sinit; + return (tree) decl->sinit; /* Class is a reference, want the record type. */ tree type = build_ctype (decl->type); @@ -2161,20 +2161,21 @@ aggregate_initializer_decl (AggregateDeclaration *decl) tree ident = mangle_internal_decl (decl, "__init", "Z"); - decl->sinit = declare_extern_var (ident, type); - DECL_LANG_SPECIFIC (decl->sinit) = build_lang_decl (NULL); + tree sinit = declare_extern_var (ident, type); + DECL_LANG_SPECIFIC (sinit) = build_lang_decl (NULL); - DECL_CONTEXT (decl->sinit) = type; - TREE_READONLY (decl->sinit) = 1; + DECL_CONTEXT (sinit) = type; + TREE_READONLY (sinit) = 1; /* Honor struct alignment set by user. */ if (sd && sd->alignment != STRUCTALIGN_DEFAULT) { - SET_DECL_ALIGN (decl->sinit, sd->alignment * BITS_PER_UNIT); - DECL_USER_ALIGN (decl->sinit) = true; + SET_DECL_ALIGN (sinit, sd->alignment * BITS_PER_UNIT); + DECL_USER_ALIGN (sinit) = true; } - return decl->sinit; + decl->sinit = sinit; + return sinit; } /* Generate the data for the static initializer. */