public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ibm/heads/gcc-9)] PR c++/91476 - anon-namespace reference temp clash between TUs.
@ 2020-02-04 21:13 Peter Bergner
  0 siblings, 0 replies; only message in thread
From: Peter Bergner @ 2020-02-04 21:13 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:3384aa7af4c4ce193f59d086f507812b88caf113

commit 3384aa7af4c4ce193f59d086f507812b88caf113
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Jan 20 14:09:03 2020 -0500

    PR c++/91476 - anon-namespace reference temp clash between TUs.
    
    	* call.c (make_temporary_var_for_ref_to_temp): Clear TREE_PUBLIC
    	if DECL is in the anonymous namespace.

Diff:
---
 gcc/cp/ChangeLog                                |  6 ++++++
 gcc/cp/call.c                                   |  2 ++
 gcc/testsuite/g++.dg/ext/visibility/ref-temp1.C | 11 +++++++++++
 3 files changed, 19 insertions(+)

diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 018ab63..0e1557c 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2020-01-21  Jason Merrill  <jason@redhat.com>
+
+	PR c++/91476 - anon-namespace reference temp clash between TUs.
+	* call.c (make_temporary_var_for_ref_to_temp): Clear TREE_PUBLIC
+	if DECL is in the anonymous namespace.
+
 2020-01-17  Jason Merrill  <jason@redhat.com>
 
 	PR c++/92531 - ICE with noexcept(lambda).
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index bc182e2..8e14e89 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -11424,6 +11424,8 @@ make_temporary_var_for_ref_to_temp (tree decl, tree type)
 
       TREE_STATIC (var) = TREE_STATIC (decl);
       TREE_PUBLIC (var) = TREE_PUBLIC (decl);
+      if (decl_anon_ns_mem_p (decl))
+	TREE_PUBLIC (var) = 0;
       if (vague_linkage_p (decl))
 	comdat_linkage (var);
 
diff --git a/gcc/testsuite/g++.dg/ext/visibility/ref-temp1.C b/gcc/testsuite/g++.dg/ext/visibility/ref-temp1.C
new file mode 100644
index 0000000..b56bb52
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/visibility/ref-temp1.C
@@ -0,0 +1,11 @@
+// PR c++/91476
+// Test that hidden and internal visibility propagates to reference temps.
+
+// { dg-final { scan-assembler-not "(weak|globl)\[^\n\]*_ZGRN12_GLOBAL__N_13fooE_" } }
+namespace { const int &foo = 1; }
+
+const void *volatile p;
+int main()
+{
+  p = &foo;
+}


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

only message in thread, other threads:[~2020-02-04 21:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-04 21:13 [gcc(refs/vendors/ibm/heads/gcc-9)] PR c++/91476 - anon-namespace reference temp clash between TUs Peter Bergner

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