diff options
| -rw-r--r-- | clang/lib/AST/Decl.cpp | 8 | ||||
| -rw-r--r-- | clang/test/CodeGen/visibility.c | 14 | 
2 files changed, 20 insertions, 2 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 2eef54cf142..ca963ad7e59 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -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 diff --git a/clang/test/CodeGen/visibility.c b/clang/test/CodeGen/visibility.c index 42b116f7aa4..fa4b5993092 100644 --- a/clang/test/CodeGen/visibility.c +++ b/clang/test/CodeGen/visibility.c @@ -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;  | 

