Ulrich Weigand | 9230997 | 2012-10-24 12:22:56 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -o - %s | FileCheck %s |
Eli Friedman | 62e22ee | 2010-08-05 07:00:53 +0000 | [diff] [blame] | 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) |
Eli Friedman | 62e22ee | 2010-08-05 07:00:53 +0000 | [diff] [blame] | 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) |
| 28 | template<int x> int f() { return x; } |
| 29 | extern "C" int g() { return f<3>(); } |
| 30 | #pragma GCC visibility pop |
| 31 | // CHECK: define hidden i32 @g() |
| 32 | // CHECK: 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 |
| 39 | template<> void x5<int>::y() {} |
| 40 | // CHECK: define hidden void @_ZN2x5IiE1yEv |
| 41 | |
| 42 | #pragma GCC visibility push(hidden) |
| 43 | namespace n __attribute((visibility("default"))) { |
| 44 | void f() {} |
| 45 | // CHECK: define void @_ZN1n1fEv |
| 46 | } |
| 47 | #pragma GCC visibility pop |
| 48 | |
| 49 | namespace n __attribute((visibility("default"))) { |
Eli Friedman | 62e22ee | 2010-08-05 07:00:53 +0000 | [diff] [blame] | 50 | #pragma GCC visibility push(hidden) |
| 51 | void g() {} |
| 52 | // CHECK: define hidden void @_ZN1n1gEv |
| 53 | #pragma GCC visibility pop |
| 54 | } |
Rafael Espindola | 71adc5b | 2012-07-17 15:14:47 +0000 | [diff] [blame] | 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 |
| 65 | static void f(){} |
| 66 | }; |
| 67 | #pragma GCC visibility pop |
| 68 | void zed() { |
| 69 | bar<foo>::f(); |
| 70 | bar<int>::f(); |
| 71 | } |
| 72 | // CHECK: define linkonce_odr hidden void @_ZN5test23barINS_3fooEE1fEv |
| 73 | // CHECK: define linkonce_odr void @_ZN5test23barIiE1fEv |
| 74 | } |