]> granicus.if.org Git - clang/commitdiff
Process #pragma visibility early in the parsing of class definitions. Fixes
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 12 Jul 2012 04:47:34 +0000 (04:47 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 12 Jul 2012 04:47:34 +0000 (04:47 +0000)
pr13338.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160105 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/CodeGenCXX/visibility.cpp

index dfe2882166bd5d348028a4150afb0c12b731a32e..47453762d9d2c2f2238ea5a04b623f76d6160edb 100644 (file)
@@ -8919,6 +8919,10 @@ void Sema::ActOnTagStartDefinition(Scope *S, Decl *TagD) {
   PushDeclContext(S, Tag);
 
   ActOnDocumentableDecl(TagD);
+
+  // If there's a #pragma GCC visibility in scope, set the visibility of this
+  // record.
+  AddPushedVisibilityAttribute(Tag);
 }
 
 Decl *Sema::ActOnObjCContainerStartDefinition(Decl *IDecl) {
@@ -8983,10 +8987,6 @@ 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();
                                           
index bf6c6eea80304f77766e36832d24a960022ff0f3..583293be527be2be170cc9a3baff563ad3cb5297 100644 (file)
@@ -1001,3 +1001,20 @@ namespace test53 {
   // CHECK: declare hidden void @_ZN6test536vectorINS_3zedEE14_M_fill_insertEv
   // CHECK-HIDDEN: declare hidden void @_ZN6test536vectorINS_3zedEE14_M_fill_insertEv
 }
+
+namespace test54 {
+  template <class T>
+  struct foo {
+    static void bar();
+  };
+#pragma GCC visibility push(hidden)
+  class zed {
+    zed(const zed &);
+  };
+  void bah() {
+    foo<zed>::bar();
+  }
+#pragma GCC visibility pop
+  // CHECK: declare hidden void @_ZN6test543fooINS_3zedEE3barEv
+  // CHECK-HIDDEN: declare hidden void @_ZN6test543fooINS_3zedEE3barEv
+}