aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaDecl.cpp4
-rw-r--r--test/CodeGenCXX/visibility.cpp16
2 files changed, 20 insertions, 0 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 17b120bc86..342acf825b 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -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)
diff --git a/test/CodeGenCXX/visibility.cpp b/test/CodeGenCXX/visibility.cpp
index 3ea232dc00..590c06e4d0 100644
--- a/test/CodeGenCXX/visibility.cpp
+++ b/test/CodeGenCXX/visibility.cpp
@@ -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
+}