1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -o - %s | FileCheck %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc #pragma GCC visibility push(hidden) 4*f4a2713aSLionel Sambuc struct x { 5*f4a2713aSLionel Sambuc static int y; 6*f4a2713aSLionel Sambuc }; 7*f4a2713aSLionel Sambuc #pragma GCC visibility pop 8*f4a2713aSLionel Sambuc int x::y = 10; 9*f4a2713aSLionel Sambuc // CHECK: @_ZN1x1yE = hidden global 10*f4a2713aSLionel Sambuc 11*f4a2713aSLionel Sambuc #pragma GCC visibility push(hidden) 12*f4a2713aSLionel Sambuc struct __attribute((visibility("default"))) x2 { 13*f4a2713aSLionel Sambuc static int y; 14*f4a2713aSLionel Sambuc }; 15*f4a2713aSLionel Sambuc int x2::y = 10; 16*f4a2713aSLionel Sambuc // CHECK: @_ZN2x21yE = global 17*f4a2713aSLionel Sambuc #pragma GCC visibility pop 18*f4a2713aSLionel Sambuc 19*f4a2713aSLionel Sambuc #pragma GCC visibility push(hidden) 20*f4a2713aSLionel Sambuc template<class T> struct x4 { 21*f4a2713aSLionel Sambuc static int y; 22*f4a2713aSLionel Sambuc }; 23*f4a2713aSLionel Sambuc #pragma GCC visibility pop 24*f4a2713aSLionel Sambuc template<> int x4<int>::y = 10; 25*f4a2713aSLionel Sambuc // CHECK: @_ZN2x4IiE1yE = hidden global i32 26*f4a2713aSLionel Sambuc 27*f4a2713aSLionel Sambuc #pragma GCC visibility push(hidden) f()28*f4a2713aSLionel Sambuctemplate<int x> int f() { return x; } g()29*f4a2713aSLionel Sambucextern "C" int g() { return f<3>(); } 30*f4a2713aSLionel Sambuc #pragma GCC visibility pop 31*f4a2713aSLionel Sambuc // CHECK-LABEL: define hidden i32 @g() 32*f4a2713aSLionel Sambuc // CHECK-LABEL: define linkonce_odr hidden i32 @_Z1fILi3EEiv() 33*f4a2713aSLionel Sambuc 34*f4a2713aSLionel Sambuc #pragma GCC visibility push(hidden) 35*f4a2713aSLionel Sambuc template<class T> struct x5 { 36*f4a2713aSLionel Sambuc void y(); 37*f4a2713aSLionel Sambuc }; 38*f4a2713aSLionel Sambuc #pragma GCC visibility pop y()39*f4a2713aSLionel Sambuctemplate<> void x5<int>::y() {} 40*f4a2713aSLionel Sambuc // CHECK-LABEL: define hidden void @_ZN2x5IiE1yEv 41*f4a2713aSLionel Sambuc 42*f4a2713aSLionel Sambuc #pragma GCC visibility push(hidden) 43*f4a2713aSLionel Sambuc namespace n __attribute((visibility("default"))) { f()44*f4a2713aSLionel Sambuc void f() {} 45*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_ZN1n1fEv 46*f4a2713aSLionel Sambuc } 47*f4a2713aSLionel Sambuc #pragma GCC visibility pop 48*f4a2713aSLionel Sambuc 49*f4a2713aSLionel Sambuc namespace n __attribute((visibility("default"))) { 50*f4a2713aSLionel Sambuc #pragma GCC visibility push(hidden) g()51*f4a2713aSLionel Sambuc void g() {} 52*f4a2713aSLionel Sambuc // CHECK-LABEL: define hidden void @_ZN1n1gEv 53*f4a2713aSLionel Sambuc #pragma GCC visibility pop 54*f4a2713aSLionel Sambuc } 55*f4a2713aSLionel Sambuc 56*f4a2713aSLionel Sambuc namespace test2 { 57*f4a2713aSLionel Sambuc #pragma GCC visibility push(default) 58*f4a2713aSLionel Sambuc #pragma GCC visibility push(hidden) 59*f4a2713aSLionel Sambuc struct foo { // foo is hidden 60*f4a2713aSLionel Sambuc }; 61*f4a2713aSLionel Sambuc #pragma GCC visibility pop 62*f4a2713aSLionel Sambuc struct foo; // declaration is ok, we ignore the default in the stack 63*f4a2713aSLionel Sambuc template<typename T> 64*f4a2713aSLionel Sambuc struct bar { // bar is default ftest2::bar65*f4a2713aSLionel Sambuc static void f(){} 66*f4a2713aSLionel Sambuc }; 67*f4a2713aSLionel Sambuc #pragma GCC visibility pop zed()68*f4a2713aSLionel Sambuc void zed() { 69*f4a2713aSLionel Sambuc bar<foo>::f(); 70*f4a2713aSLionel Sambuc bar<int>::f(); 71*f4a2713aSLionel Sambuc } 72*f4a2713aSLionel Sambuc // CHECK-LABEL: define linkonce_odr hidden void @_ZN5test23barINS_3fooEE1fEv 73*f4a2713aSLionel Sambuc // CHECK-LABEL: define linkonce_odr void @_ZN5test23barIiE1fEv 74*f4a2713aSLionel Sambuc } 75