1// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s 2 3#pragma GCC visibility push(hidden) 4struct x { 5 static int y; 6}; 7#pragma GCC visibility pop 8int x::y = 10; 9// CHECK: @_ZN1x1yE = hidden global 10 11#pragma GCC visibility push(hidden) 12struct __attribute((visibility("default"))) x2 { 13 static int y; 14}; 15int x2::y = 10; 16// CHECK: @_ZN2x21yE = global 17#pragma GCC visibility pop 18 19#pragma GCC visibility push(hidden) 20struct x3 { 21 static int y; 22} __attribute((visibility("default"))); 23int x3::y = 10; 24// CHECK: @_ZN2x31yE = global 25#pragma GCC visibility pop 26 27#pragma GCC visibility push(hidden) 28template<class T> struct x4 { 29 static int y; 30}; 31#pragma GCC visibility pop 32template<> int x4<int>::y = 10; 33// CHECK: @_ZN2x4IiE1yE = hidden global i32 34 35#pragma GCC visibility push(hidden) 36template<int x> int f() { return x; } 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) 43template<class T> struct x5 { 44 void y(); 45}; 46#pragma GCC visibility pop 47template<> void x5<int>::y() {} 48// CHECK: define hidden void @_ZN2x5IiE1yEv 49 50#pragma GCC visibility push(hidden) 51namespace n __attribute((visibility("default"))) { 52 void f() {} 53 // CHECK: define void @_ZN1n1fEv 54} 55#pragma GCC visibility pop 56 57namespace 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) 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. 68namespace 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 72 void h() {} 73 // CHECK disabled: define void @_ZN1n1hEv 74} 75