1 // RUN: %clang_cc1 %s -triple i386-unknown-unknown -fvisibility default -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-DEFAULT
2 // RUN: %clang_cc1 %s -triple i386-unknown-unknown -fvisibility protected -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-PROTECTED
3 // RUN: %clang_cc1 %s -triple i386-unknown-unknown -fvisibility hidden -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-HIDDEN
5 // CHECK-DEFAULT: @g_def = global i32 0
6 // CHECK-DEFAULT: @g_com = common global i32 0
7 // CHECK-DEFAULT: @g_ext = external global i32
8 // CHECK-DEFAULT: @g_deferred = internal global
9 // CHECK-PROTECTED: @g_def = protected global i32 0
10 // CHECK-PROTECTED: @g_com = common protected global i32 0
11 // CHECK-PROTECTED: @g_ext = external global i32
12 // CHECK-PROTECTED: @g_deferred = internal global
13 // CHECK-HIDDEN: @g_def = hidden global i32 0
14 // CHECK-HIDDEN: @g_com = common hidden global i32 0
15 // CHECK-HIDDEN: @g_ext = external global i32
16 // CHECK-HIDDEN: @g_deferred = internal global
20 static char g_deferred
[] = "hello";
22 // CHECK-DEFAULT: @test4 = hidden global i32 10
23 // CHECK-PROTECTED: @test4 = hidden global i32 10
24 // CHECK-HIDDEN: @test4 = hidden global i32 10
26 // CHECK-DEFAULT: define i32 @f_def()
27 // CHECK-DEFAULT: declare void @f_ext()
28 // CHECK-DEFAULT: define internal void @f_deferred()
29 // CHECK-PROTECTED: define protected i32 @f_def()
30 // CHECK-PROTECTED: declare void @f_ext()
31 // CHECK-PROTECTED: define internal void @f_deferred()
32 // CHECK-HIDDEN: define hidden i32 @f_def()
33 // CHECK-HIDDEN: declare void @f_ext()
34 // CHECK-HIDDEN: define internal void @f_deferred()
36 extern void f_ext(void);
38 static void f_deferred(void) {
44 return g_com
+ g_def
+ g_ext
+ g_deferred
[0];
48 // CHECK-DEFAULT: define void @test1(
49 // CHECK-PROTECTED: define void @test1(
50 // CHECK-HIDDEN: define void @test1(
51 struct Test1
{ int field
; };
52 void __attribute__((visibility("default"))) test1(struct Test1
*v
) { }
54 // rdar://problem/8595231
55 // CHECK-DEFAULT: define void @test2()
56 // CHECK-PROTECTED: define void @test2()
57 // CHECK-HIDDEN: define void @test2()
59 void __attribute__((visibility("default"))) test2(void) {}
61 // CHECK-DEFAULT: define hidden void @test3()
62 // CHECK-PROTECTED: define hidden void @test3()
63 // CHECK-HIDDEN: define hidden void @test3()
64 extern void test3(void);
65 __private_extern__
void test3(void) {}
69 __private_extern__
int test4
= 10;