From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1873) id 933C23951429; Wed, 14 Apr 2021 12:44:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 933C23951429 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 r11-8173] d: Move call to set_linkage_for_decl to declare_extern_var. X-Act-Checkin: gcc X-Git-Author: Iain Buclaw X-Git-Refname: refs/heads/master X-Git-Oldrev: 3785d2b207f1958f31a79fbbb5705b261551950d X-Git-Newrev: 5b63eb17d863ac080cf3c7df08233054b09d3747 Message-Id: <20210414124412.933C23951429@sourceware.org> Date: Wed, 14 Apr 2021 12:44:12 +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: Wed, 14 Apr 2021 12:44:12 -0000 https://gcc.gnu.org/g:5b63eb17d863ac080cf3c7df08233054b09d3747 commit r11-8173-g5b63eb17d863ac080cf3c7df08233054b09d3747 Author: Iain Buclaw Date: Tue Apr 13 16:19:03 2021 +0200 d: Move call to set_linkage_for_decl to declare_extern_var. This both prevents against it being called twice for declarations that are defined, and fixes an issue where variables defined in the compilation get one kind of linkage (weak), and the same variables declared via declare_extern_var get another (extern). gcc/d/ChangeLog: PR d/99914 * decl.cc (DeclVisitor::visit (StructDeclaration *)): Don't set DECL_INSTANTIATED on static initializer declarations. (DeclVisitor::visit (ClassDeclaration *)): Likewise. (DeclVisitor::visit (EnumDeclaration *)): Likewise. (d_finish_decl): Move call to set_linkage_for_decl to... (declare_extern_var): ...here. Diff: --- gcc/d/decl.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc index b07068ed6ca..8948e40e902 100644 --- a/gcc/d/decl.cc +++ b/gcc/d/decl.cc @@ -387,7 +387,6 @@ public: /* Generate static initializer. */ d->sinit = aggregate_initializer_decl (d); DECL_INITIAL (d->sinit) = layout_struct_initializer (d); - DECL_INSTANTIATED (d->sinit) = (d->isInstantiated () != NULL); d_finish_decl (d->sinit); /* Put out the members. There might be static constructors in the members @@ -500,7 +499,6 @@ public: /* Generate static initializer. */ DECL_INITIAL (d->sinit) = layout_class_initializer (d); - DECL_INSTANTIATED (d->sinit) = (d->isInstantiated () != NULL); d_finish_decl (d->sinit); /* Put out the TypeInfo. */ @@ -611,7 +609,6 @@ public: /* Generate static initializer. */ d->sinit = enum_initializer_decl (d); DECL_INITIAL (d->sinit) = build_expr (tc->sym->defaultval, true); - DECL_INSTANTIATED (d->sinit) = (d->isInstantiated () != NULL); d_finish_decl (d->sinit); } @@ -1379,6 +1376,8 @@ declare_extern_var (tree ident, tree type) /* The decl has not been defined -- yet. */ DECL_EXTERNAL (decl) = 1; + set_linkage_for_decl (decl); + return decl; } @@ -1540,7 +1539,6 @@ d_finish_decl (tree decl) set_decl_tls_model (decl, decl_default_tls_model (decl)); relayout_decl (decl); - set_linkage_for_decl (decl); if (flag_checking && DECL_INITIAL (decl)) {