re PR c++/51813 (-fvisibility=hidden causes std::codecvt members to be undefined)
authorJason Merrill <jason@redhat.com>
Fri, 13 Jan 2012 17:50:58 +0000 (12:50 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 13 Jan 2012 17:50:58 +0000 (12:50 -0500)
PR c++/51813
* decl2.c (constrain_visibility): Clear DECL_VISIBILITY_SPECIFIED
when reducing the visibility.

From-SVN: r183156

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

index 58210f12e64308107ae7f5609763dbb0a81528d5..19d4eccc45d1b5ccea5f9076b3c4b4a3f111537a 100644 (file)
@@ -1,5 +1,9 @@
 2012-01-13  Jason Merrill  <jason@redhat.com>
 
+       PR c++/51813
+       * decl2.c (constrain_visibility): Clear DECL_VISIBILITY_SPECIFIED
+       when reducing the visibility.
+
        PR c++/51620
        * class.c (build_vtbl_initializer): Use __cxa_deleted_virtual.
 
index 05f4b42ac73bf1e6bb7e034fd8ba7d21c6ecd1ee..0cde6c66149ecd25c7d4cf0b9f3f771cb15ffb1e 100644 (file)
@@ -1984,6 +1984,8 @@ constrain_visibility (tree decl, int visibility, bool tmpl)
           && (tmpl || !DECL_VISIBILITY_SPECIFIED (decl)))
     {
       DECL_VISIBILITY (decl) = (enum symbol_visibility) visibility;
+      /* This visibility was not specified.  */
+      DECL_VISIBILITY_SPECIFIED (decl) = false;
     }
 }
 
index 2778556b8e3061f45799a4bc33fc326ad4d6c7ef..12d5830a0a2dd149c63b51e4a9e27fc178718698 100644 (file)
@@ -1,5 +1,8 @@
 2012-01-13  Jason Merrill  <jason@redhat.com>
 
+       PR c++/51813
+       * g++.dg/ext/visibility/template9.C: New.
+
        PR c++/51620
        * g++.dg/cpp0x/defaulted34.C: New.
        * g++.dg/template/virtual3.C: New.
diff --git a/gcc/testsuite/g++.dg/ext/visibility/template9.C b/gcc/testsuite/g++.dg/ext/visibility/template9.C
new file mode 100644 (file)
index 0000000..d160846
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/51813
+// { dg-options -fvisibility=hidden }
+// { dg-final { scan-assembler-not "hidden\\s+_ZN1N1fI1AEEvT" } }
+
+struct A { };
+namespace N __attribute((visibility("default"))) {
+  template <class T> void f(T) { }
+  extern template void f(A);
+}
+
+int main()
+{
+  N::f(A());
+}