John McCall | f9536f4 | 2011-02-08 22:28:39 +0000 | [diff] [blame] | 1 | // This is an IR generation test because the calculation of visibility |
| 2 | // during IR gen will cause linkage to be implicitly recomputed and |
| 3 | // compared against the earlier cached value. If we had a way of |
| 4 | // testing linkage directly in Sema, that would be better. |
| 5 | |
| 6 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck %s |
| 7 | |
| 8 | // PR8926 |
| 9 | namespace test0 { |
| 10 | typedef struct { |
| 11 | void *foo() { return 0; } |
| 12 | } A; |
| 13 | |
| 14 | // CHECK: define linkonce_odr i8* @_ZN5test01A3fooEv( |
| 15 | |
| 16 | void test(A *a) { |
| 17 | a->foo(); |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | namespace test1 { |
| 22 | typedef struct { |
| 23 | template <unsigned n> void *foo() { return 0; } |
| 24 | |
| 25 | void foo() { |
| 26 | foo<0>(); |
| 27 | } |
| 28 | } A; |
| 29 | |
| 30 | // CHECK: define linkonce_odr void @_ZN5test11A3fooEv( |
| 31 | // another at the end |
| 32 | |
| 33 | void test(A *a) { |
| 34 | a->foo(); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | namespace test2 { |
| 39 | typedef struct { |
| 40 | template <unsigned n> struct B { |
| 41 | void *foo() { return 0; } |
| 42 | }; |
| 43 | |
| 44 | void foo(B<0> *b) { |
| 45 | b->foo(); |
| 46 | } |
| 47 | } A; |
| 48 | |
| 49 | // CHECK: define linkonce_odr void @_ZN5test21A3fooEPNS0_1BILj0EEE( |
| 50 | |
| 51 | void test(A *a) { |
| 52 | a->foo(0); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | // CHECK: define linkonce_odr i8* @_ZN5test21A1BILj0EE3fooEv( |
| 57 | // CHECK: define linkonce_odr i8* @_ZN5test11A3fooILj0EEEPvv( |