public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [pushed] c++: visibility of local extern [PR103291]
@ 2022-03-28 13:34 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2022-03-28 13:34 UTC (permalink / raw)
  To: gcc-patches

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-28 13:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-28 13:34 [pushed] c++: visibility of local extern [PR103291] Jason Merrill

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).