* decl2.c (get_guard): Copy visibility from the guarded variable.
authorJason Merrill <jason@redhat.com>
Fri, 7 Sep 2007 03:56:41 +0000 (23:56 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 7 Sep 2007 03:56:41 +0000 (23:56 -0400)
From-SVN: r128226

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/testsuite/g++.dg/ext/visibility/guard1.C [new file with mode: 0644]

index 12cdd809750ac49acf25169dc8f30403a5702e4f..b5229b3814df68bc48a535e2fe2758ea6a60bcce 100644 (file)
@@ -1,3 +1,7 @@
+2007-09-06  Jason Merrill  <jason@redhat.com>
+
+       * decl2.c (get_guard): Copy visibility from the guarded variable.
+
 2007-09-06  Jan Hubicka  <jh@suse.cz>
 
        * semantics.c (expand_body): Do not mark arguments of clones used.
index 2708e5819f9fc88843f2120896d1b19080c43fd2..db578d85cc3686e055f0401fa30a9d0bd015d4e5 100644 (file)
@@ -2215,6 +2215,8 @@ get_guard (tree decl)
       DECL_ONE_ONLY (guard) = DECL_ONE_ONLY (decl);
       if (TREE_PUBLIC (decl))
        DECL_WEAK (guard) = DECL_WEAK (decl);
+      DECL_VISIBILITY (guard) = DECL_VISIBILITY (decl);
+      DECL_VISIBILITY_SPECIFIED (guard) = DECL_VISIBILITY_SPECIFIED (decl);
 
       DECL_ARTIFICIAL (guard) = 1;
       DECL_IGNORED_P (guard) = 1;
diff --git a/gcc/testsuite/g++.dg/ext/visibility/guard1.C b/gcc/testsuite/g++.dg/ext/visibility/guard1.C
new file mode 100644 (file)
index 0000000..5290e2f
--- /dev/null
@@ -0,0 +1,29 @@
+// { dg-options "-fvisibility=hidden" }
+// { dg-require-visibility "" }
+// { dg-final { scan-not-hidden "_ZGVZN5otherclEvE4s_cd" } }
+
+extern "C" int printf (const char *, ...);
+
+#define DLLEXPORT __attribute__ ((visibility("default")))
+
+struct class_data
+{
+  int apple;
+  class_data() { printf("non trivial ctor\n"); }
+};
+
+struct DLLEXPORT other
+{
+  class_data* operator ()()
+  {
+    static class_data s_cd;
+    return &s_cd;
+  }
+};
+
+int main()
+{
+  other aFoo;
+  aFoo();
+  return 0;
+}