public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Iain Buclaw <ibuclaw@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/ibuclaw/heads/mingw)] d: Move call to set_linkage_for_decl to declare_extern_var. Date: Tue, 13 Apr 2021 20:42:07 +0000 (GMT) [thread overview] Message-ID: <20210413204207.9CCC23951E44@sourceware.org> (raw) https://gcc.gnu.org/g:5718dd9e674b6c7dc5497ea247faa6fd20e53e52 commit 5718dd9e674b6c7dc5497ea247faa6fd20e53e52 Author: Iain Buclaw <ibuclaw@gdcproject.org> 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 variables declared via declare_extern_var get another (global). 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)) {
reply other threads:[~2021-04-13 20:42 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210413204207.9CCC23951E44@sourceware.org \ --to=ibuclaw@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).