]> granicus.if.org Git - clang/commitdiff
Unbreak private_extern, which apparently we had zero tests for.
authorJohn McCall <rjmccall@apple.com>
Tue, 2 Nov 2010 18:38:13 +0000 (18:38 +0000)
committerJohn McCall <rjmccall@apple.com>
Tue, 2 Nov 2010 18:38:13 +0000 (18:38 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118034 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Decl.cpp
test/CodeGen/visibility.c

index 2eef54cf142c63a66e1b9093e83257588c58110f..ca963ad7e599832236f963b94bd5899c6b56396d 100644 (file)
@@ -278,11 +278,12 @@ static LinkageInfo getLVForNamespaceScopeDecl(const NamedDecl *D, LVFlags F) {
         LV.mergeVisibility(TypeLV.second);
     }
 
+    if (Var->getStorageClass() == SC_PrivateExtern)
+      LV.setVisibility(HiddenVisibility, true);
+
     if (!Context.getLangOptions().CPlusPlus &&
         (Var->getStorageClass() == SC_Extern ||
          Var->getStorageClass() == SC_PrivateExtern)) {
-      if (Var->getStorageClass() == SC_PrivateExtern)
-        LV.setVisibility(HiddenVisibility, true);
 
       // C99 6.2.2p4:
       //   For an identifier declared with the storage-class specifier
@@ -307,6 +308,9 @@ static LinkageInfo getLVForNamespaceScopeDecl(const NamedDecl *D, LVFlags F) {
     // for justification).  In practice, GCC doesn't do this, so it's
     // just too painful to make work.
 
+    if (Function->getStorageClass() == SC_PrivateExtern)
+      LV.setVisibility(HiddenVisibility, true);
+
     // C99 6.2.2p5:
     //   If the declaration of an identifier for a function has no
     //   storage-class specifier, its linkage is determined exactly
index 42b116f7aa4fabb7969913188844e42a35635cff..fa4b5993092cdc5389e0b744953a212e02144380 100644 (file)
@@ -19,6 +19,10 @@ int g_def = 0;
 extern int g_ext;
 static char g_deferred[] = "hello";
 
+// CHECK-DEFAULT: @test4 = hidden global i32 10
+// CHECK-PROTECTED: @test4 = hidden global i32 10
+// CHECK-HIDDEN: @test4 = hidden global i32 10
+
 // CHECK-DEFAULT: define i32 @f_def()
 // CHECK-DEFAULT: declare void @f_ext()
 // CHECK-DEFAULT: define internal void @f_deferred()
@@ -53,3 +57,13 @@ void  __attribute__((visibility("default"))) test1(struct Test1 *v) { }
 // CHECK-HIDDEN: define void @test2()
 void test2(void);
 void __attribute__((visibility("default"))) test2(void) {}
+
+// CHECK-DEFAULT: define hidden void @test3()
+// CHECK-PROTECTED: define hidden void @test3()
+// CHECK-HIDDEN: define hidden void @test3()
+extern void test3(void);
+__private_extern__ void test3(void) {}
+
+// Top of file.
+extern int test4;
+__private_extern__ int test4 = 10;