From: Rafael Espindola Date: Wed, 11 Jul 2012 02:15:51 +0000 (+0000) Subject: Don't process #pragma visibility during instantiation. The visibility of the X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f2f15b3bc6820469024db170c87ffe885ec53cf9;p=clang Don't process #pragma visibility during instantiation. The visibility of the instantiation depends on the template, its arguments and parameters, but not where it is instantiated. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160034 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index f9a487270b..576cbd150a 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -10062,7 +10062,8 @@ void Sema::ActOnFields(Scope* S, // If there's a #pragma GCC visibility in scope, and this isn't a subclass, // set the visibility of this record. - if (Record && !Record->getDeclContext()->isRecord()) + if (Record && !Record->getDeclContext()->isRecord() && + !isa(Record)) AddPushedVisibilityAttribute(Record); } diff --git a/test/CodeGenCXX/visibility.cpp b/test/CodeGenCXX/visibility.cpp index a398a45e58..60a77927ff 100644 --- a/test/CodeGenCXX/visibility.cpp +++ b/test/CodeGenCXX/visibility.cpp @@ -974,3 +974,16 @@ namespace test52 { // CHECK: define internal void @_ZN6test523zedILPNS_12_GLOBAL__N_13fooE0EEEvv // CHECK-HIDDEN: define internal void @_ZN6test523zedILPNS_12_GLOBAL__N_13fooE0EEEvv } + +namespace test53 { + template struct vector { + static void _M_fill_insert(); + }; +#pragma GCC visibility push(hidden) + void foo() { + vector::_M_fill_insert(); + } +#pragma GCC visibility pop + // CHECK: declare void @_ZN6test536vectorIjE14_M_fill_insertEv + // CHECK-HIDDEN: declare void @_ZN6test536vectorIjE14_M_fill_insertEv +}