blob: 2389839921b67e4ddf9d1b00a7259bae713c84c0 [file] [log] [blame]
Anders Carlsson68fdb872010-03-24 00:41:37 +00001// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
2
3namespace Test1 {
4
5// Check that we emit a non-virtual thunk for C::f.
6
7struct A {
8 virtual void f();
9};
10
11struct B {
12 virtual void f();
13};
14
15struct C : A, B {
16 virtual void c();
17
18 virtual void f();
19};
20
21// CHECK: define weak void @_ZThn8_N5Test11C1fEv(
22void C::f() { }
23
24}
25
26namespace Test2 {
27
28// Check that we emit a thunk for B::f since it's overriding a virtual base.
29
30struct A {
31 virtual void f();
32};
33
34struct B : virtual A {
35 virtual void b();
36 virtual void f();
37};
38
39// CHECK: define weak void @_ZTv0_n24_N5Test21B1fEv(
40void B::f() { }
41
42}
43
44namespace Test3 {
45
46// Check that we emit a covariant thunk for B::f.
47
48struct V1 { };
49struct V2 : virtual V1 { };
50
51struct A {
52 virtual V1 *f();
53};
54
55struct B : A {
56 virtual void b();
57
58 virtual V2 *f();
59};
60
61// CHECK: define weak %{{.*}}* @_ZTch0_v0_n24_N5Test31B1fEv(
62V2 *B::f() { return 0; }
63
64}
65
66namespace Test4 {
67
68// Check that the thunk for 'C::f' has the same visibility as the function itself.
69
70struct A {
71 virtual void f();
72};
73
74struct B {
75 virtual void f();
76};
77
78struct __attribute__((visibility("protected"))) C : A, B {
79 virtual void c();
80
81 virtual void f();
82};
83
84// CHECK: define weak protected void @_ZThn8_N5Test41C1fEv(
85void C::f() { }
86
87}
88
89// Check that the thunk gets internal linkage.
90namespace {
91
92struct A {
93 virtual void f();
94};
95
96struct B {
97 virtual void f();
98};
99
100struct C : A, B {
101 virtual void c();
102
103 virtual void f();
104};
105
106// CHECK: define internal void @_ZThn8_N12_GLOBAL__N_11C1fEv(
107void C::f() { }
108
109}
110
111// Force C::f to be used.
112void f() {
113 C c;
114
115 c.f();
116}