1 // RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s 2 3 #pragma GCC visibility push(hidden) 4 struct x { 5 static int y; 6 }; 7 #pragma GCC visibility pop 8 int x::y = 10; 9 // CHECK: @_ZN1x1yE = hidden global 10 11 #pragma GCC visibility push(hidden) 12 struct __attribute((visibility("default"))) x2 { 13 static int y; 14 }; 15 int x2::y = 10; 16 // CHECK: @_ZN2x21yE = global 17 #pragma GCC visibility pop 18 19 #pragma GCC visibility push(hidden) 20 struct x3 { 21 static int y; 22 } __attribute((visibility("default"))); 23 int x3::y = 10; 24 // CHECK: @_ZN2x31yE = global 25 #pragma GCC visibility pop 26 27 #pragma GCC visibility push(hidden) 28 template<class T> struct x4 { 29 static int y; 30 }; 31 #pragma GCC visibility pop 32 template<> int x4<int>::y = 10; 33 // CHECK: @_ZN2x4IiE1yE = hidden global i32 34 35 #pragma GCC visibility push(hidden) f()36template<int x> int f() { return x; } g()37extern "C" int g() { return f<3>(); } 38 #pragma GCC visibility pop 39 // CHECK: define hidden i32 @g() 40 // CHECK: define linkonce_odr hidden i32 @_Z1fILi3EEiv() 41 42 #pragma GCC visibility push(hidden) 43 template<class T> struct x5 { 44 void y(); 45 }; 46 #pragma GCC visibility pop y()47template<> void x5<int>::y() {} 48 // CHECK: define hidden void @_ZN2x5IiE1yEv 49 50 #pragma GCC visibility push(hidden) 51 namespace n __attribute((visibility("default"))) { f()52 void f() {} 53 // CHECK: define void @_ZN1n1fEv 54 } 55 #pragma GCC visibility pop 56 57 namespace n __attribute((visibility("default"))) { 58 extern int foofoo; // FIXME: Shouldn't be necessary, but otherwise the pragma 59 // gets to Sema before the namespace! 60 #pragma GCC visibility push(hidden) g()61 void g() {} 62 // CHECK: define hidden void @_ZN1n1gEv 63 #pragma GCC visibility pop 64 } 65 66 // We used to test this, but it's insane, so unless it happens in 67 // headers, we should not support it. 68 namespace n __attribute((visibility("hidden"))) { 69 extern int foofoo; // FIXME: Shouldn't be necessary, but otherwise the pragma 70 // gets to Sema before the namespace! 71 #pragma GCC visibility pop h()72 void h() {} 73 // CHECK disabled: define void @_ZN1n1hEv 74 } 75