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