From fc97053254977c2709b8eca3caed6558e2ade7e2 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 13 Jan 2012 12:50:58 -0500 Subject: [PATCH] re PR c++/51813 (-fvisibility=hidden causes std::codecvt members to be undefined) PR c++/51813 * decl2.c (constrain_visibility): Clear DECL_VISIBILITY_SPECIFIED when reducing the visibility. From-SVN: r183156 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/decl2.c | 2 ++ gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/ext/visibility/template9.C | 14 ++++++++++++++ 4 files changed, 23 insertions(+) create mode 100644 gcc/testsuite/g++.dg/ext/visibility/template9.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 58210f12e64..19d4eccc45d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2012-01-13 Jason Merrill + 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. diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 05f4b42ac73..0cde6c66149 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -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; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2778556b8e3..12d5830a0a2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2012-01-13 Jason Merrill + 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 index 00000000000..d1608467269 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/visibility/template9.C @@ -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 void f(T) { } + extern template void f(A); +} + +int main() +{ + N::f(A()); +}