public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [pushed] c++: visibility of local extern [PR103291]
Date: Mon, 28 Mar 2022 09:34:22 -0400	[thread overview]
Message-ID: <20220328133422.2586321-1-jason@redhat.com> (raw)

When setting up the hidden namespace-scope decl for a local extern, we also
need to set its visibility.

Tested x86_64-pc-linux-gnu, applying to trunk.

	PR c++/103291

gcc/cp/ChangeLog:

	* name-lookup.cc (push_local_extern_decl_alias): Call
	determine_visibility.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/visibility/visibility-local-extern1.C: New test.
---
 gcc/cp/name-lookup.cc                                  |  3 +++
 .../g++.dg/ext/visibility/visibility-local-extern1.C   | 10 ++++++++++
 2 files changed, 13 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/ext/visibility/visibility-local-extern1.C

diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc
index 3c7b626350f..c833b84ca8a 100644
--- a/gcc/cp/name-lookup.cc
+++ b/gcc/cp/name-lookup.cc
@@ -3476,6 +3476,9 @@ push_local_extern_decl_alias (tree decl)
 	      && CP_DECL_THREAD_LOCAL_P (decl)
 	      && alias != error_mark_node)
 	    set_decl_tls_model (alias, DECL_TLS_MODEL (decl));
+
+	  /* Adjust visibility.  */
+	  determine_visibility (alias);
 	}
     }
 
diff --git a/gcc/testsuite/g++.dg/ext/visibility/visibility-local-extern1.C b/gcc/testsuite/g++.dg/ext/visibility/visibility-local-extern1.C
new file mode 100644
index 00000000000..40c20199d0c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/visibility/visibility-local-extern1.C
@@ -0,0 +1,10 @@
+// PR c++/103291
+// { dg-additional-options -fpic }
+// { dg-final { scan-assembler-not "@GOTPCREL" } }
+
+#pragma GCC visibility push(hidden)
+
+int hidden_fetch(void) {
+  extern const int hidden_global;
+  return hidden_global;
+}

base-commit: bc86a86a4f2c057bc0e0be94dcbb8c128ae7f717
prerequisite-patch-id: 09e711b54e7911a4a04bd7808abc1b73ae4482ba
prerequisite-patch-id: 566cf0772894d0c6a842b2e0ca62eb1d5ae8ad33
prerequisite-patch-id: b1def7e83e76c1652efb483cb2b67e472d15b720
prerequisite-patch-id: 12973b1310781ff6ce5c9792ea689f0673fc5251
prerequisite-patch-id: 8dcc4ecc29dbe7b290325412af70613171456714
prerequisite-patch-id: 0e11ad2f06a4b425182bca51bd5a85eedd3ce8cd
prerequisite-patch-id: 1c17a86736dd239bc62ee4619599fc89f0cf5908
-- 
2.27.0


                 reply	other threads:[~2022-03-28 13:34 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=20220328133422.2586321-1-jason@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@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: link
Be 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).