From 35cebc3eea898637057b10b5cf7dd08b1d788980 Mon Sep 17 00:00:00 2001 From: John McCall Date: Tue, 2 Nov 2010 18:38:13 +0000 Subject: [PATCH] Unbreak private_extern, which apparently we had zero tests for. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118034 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/Decl.cpp | 8 ++++++-- test/CodeGen/visibility.c | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 2eef54cf14..ca963ad7e5 100644 --- a/lib/AST/Decl.cpp +++ b/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/test/CodeGen/visibility.c b/test/CodeGen/visibility.c index 42b116f7aa..fa4b599309 100644 --- a/test/CodeGen/visibility.c +++ b/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; -- 2.40.0