From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1873) id 69D7E393D003; Fri, 30 Jul 2021 10:56:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 69D7E393D003 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 r12-2617] d: Factor aggregate_initializer_decl to set the sinit for aggregate declarations. X-Act-Checkin: gcc X-Git-Author: Iain Buclaw X-Git-Refname: refs/heads/master X-Git-Oldrev: 3b52a1086c1358a7694ebe0c7610058c48e93b22 X-Git-Newrev: 99d6d3d92f24c249314e0509f1ffa68f8450495e Message-Id: <20210730105601.69D7E393D003@sourceware.org> Date: Fri, 30 Jul 2021 10:56:01 +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: Fri, 30 Jul 2021 10:56:01 -0000 https://gcc.gnu.org/g:99d6d3d92f24c249314e0509f1ffa68f8450495e commit r12-2617-g99d6d3d92f24c249314e0509f1ffa68f8450495e Author: Iain Buclaw Date: Mon Jul 26 18:40:35 2021 +0200 d: Factor aggregate_initializer_decl to set the sinit for aggregate declarations. 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. Diff: --- 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. */