public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r11-9702] c++: visibility of local extern [PR103291]
Date: Mon, 28 Mar 2022 19:12:47 +0000 (GMT)	[thread overview]
Message-ID: <20220328191247.0E5093858C50@sourceware.org> (raw)

https://gcc.gnu.org/g:10dcd13ff7a9f0fbbae8749929e8808792c76395

commit r11-9702-g10dcd13ff7a9f0fbbae8749929e8808792c76395
Author: Jason Merrill <jason@redhat.com>
Date:   Sun Mar 27 09:44:59 2022 -0400

    c++: visibility of local extern [PR103291]
    
    When setting up the hidden namespace-scope decl for a local extern, we also
    need to set its visibility.
    
            PR c++/103291
    
    gcc/cp/ChangeLog:
    
            * name-lookup.c (push_local_extern_decl_alias): Call
            determine_visibility.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/ext/visibility/visibility-local-extern1.C: New test.

Diff:
---
 gcc/cp/name-lookup.c                                           |  3 +++
 gcc/testsuite/g++.dg/ext/visibility/visibility-local-extern1.C | 10 ++++++++++
 2 files changed, 13 insertions(+)

diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index c9ac3db4d98..e9af670c28f 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -3481,6 +3481,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;
+}


                 reply	other threads:[~2022-03-28 19:12 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=20220328191247.0E5093858C50@sourceware.org \
    --to=jason@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: 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).