diff options
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 10 | ||||
-rw-r--r-- | test/CodeGenCXX/visibility.cpp | 14 |
2 files changed, 18 insertions, 6 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 576cbd150a..607f57d74f 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -8931,6 +8931,10 @@ void Sema::ActOnTagFinishDefinition(Scope *S, Decl *TagD, if (isa<CXXRecordDecl>(Tag)) FieldCollector->FinishClass(); + // If there's a #pragma GCC visibility in scope, and this isn't a subclass, + // set the visibility of this record. + AddPushedVisibilityAttribute(Tag); + // Exit this scope of this tag's definition. PopDeclContext(); @@ -10059,12 +10063,6 @@ void Sema::ActOnFields(Scope* S, if (Attr) ProcessDeclAttributeList(S, Record, Attr); - - // 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() && - !isa<ClassTemplateSpecializationDecl>(Record)) - AddPushedVisibilityAttribute(Record); } /// \brief Determine whether the given integral value is representable within diff --git a/test/CodeGenCXX/visibility.cpp b/test/CodeGenCXX/visibility.cpp index 60a77927ff..bf6c6eea80 100644 --- a/test/CodeGenCXX/visibility.cpp +++ b/test/CodeGenCXX/visibility.cpp @@ -980,10 +980,24 @@ namespace test53 { static void _M_fill_insert(); }; #pragma GCC visibility push(hidden) + // GCC doesn't seem to use the visibility of enums at all, we do. + enum zed {v1}; + + // GCC fails to mark this specialization hidden, we mark it. + template<> + struct vector<int> { + static void _M_fill_insert(); + }; void foo() { vector<unsigned>::_M_fill_insert(); + vector<int>::_M_fill_insert(); + vector<zed>::_M_fill_insert(); } #pragma GCC visibility pop // CHECK: declare void @_ZN6test536vectorIjE14_M_fill_insertEv // CHECK-HIDDEN: declare void @_ZN6test536vectorIjE14_M_fill_insertEv + // CHECK: declare hidden void @_ZN6test536vectorIiE14_M_fill_insertEv + // CHECK-HIDDEN: declare hidden void @_ZN6test536vectorIiE14_M_fill_insertEv + // CHECK: declare hidden void @_ZN6test536vectorINS_3zedEE14_M_fill_insertEv + // CHECK-HIDDEN: declare hidden void @_ZN6test536vectorINS_3zedEE14_M_fill_insertEv } |