]> granicus.if.org Git - clang/commitdiff
Record visibility pragmas when we see a tag declaration. We might use it
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 17 Jul 2012 04:22:25 +0000 (04:22 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 17 Jul 2012 04:22:25 +0000 (04:22 +0000)
to build a type before seeing the definition.

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

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

index 17b120bc8663a95845d8838594279b8bbad93870..342acf825b587629bfc630b3a5e9f112f17cb748 100644 (file)
@@ -8880,6 +8880,10 @@ CreateNewDecl:
   if (Attr)
     ProcessDeclAttributeList(S, New, Attr);
 
+  // If there's a #pragma GCC visibility in scope, set the visibility of this
+  // record.
+  AddPushedVisibilityAttribute(New);
+
   // If we're declaring or defining a tag in function prototype scope
   // in C, note that this type can only be used within the function.
   if (Name && S->isFunctionPrototypeScope() && !getLangOpts().CPlusPlus)
index 3ea232dc00baa984dae36eea6f1f1fbc3c570572..590c06e4d0f63057e3adec15e8a366b2095ad2a5 100644 (file)
@@ -1061,3 +1061,19 @@ namespace test57 {
   // CHECK: declare hidden void @_ZN6test573fooIiE3zedEv
   // CHECK-HIDDEN: declare hidden void @_ZN6test573fooIiE3zedEv
 }
+
+namespace test58 {
+#pragma GCC visibility push(hidden)
+  struct foo;
+  template<typename T>
+  struct __attribute__((visibility("default"))) bar {
+    static void zed() {
+    }
+  };
+  void bah() {
+    bar<foo>::zed();
+  }
+#pragma GCC visibility pop
+  // CHECK: define linkonce_odr hidden void @_ZN6test583barINS_3fooEE3zedEv
+  // CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test583barINS_3fooEE3zedEv
+}