blob: b93a310b00f743ca5ebcc21705dc0497d9c98ed1 [file] [log] [blame]
John McCallf9536f42011-02-08 22:28:39 +00001// 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
9namespace 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
21namespace 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
38namespace 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
John McCallaf8ca372011-02-10 06:50:24 +000056namespace test3 {
57 namespace { struct A {}; }
58
59 // CHECK: define internal void @_ZN5test34testENS_12_GLOBAL__N_11AE(
60 void test(A a) {}
61 void force() { test(A()); }
62
63 // CHECK: define void @test3(
64 extern "C" void test3(A a) {}
65}
66
Chandler Carruth094b6432011-02-24 19:03:39 +000067namespace {
68 // CHECK: define void @test4(
69 extern "C" void test4(void) {}
70}
71
John McCallf9536f42011-02-08 22:28:39 +000072// CHECK: define linkonce_odr i8* @_ZN5test21A1BILj0EE3fooEv(
73// CHECK: define linkonce_odr i8* @_ZN5test11A3fooILj0EEEPvv(