xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/thunk-linkonce-odr.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -triple i386-unknown-unknown -emit-llvm -o - | FileCheck %s
2*f4a2713aSLionel Sambuc // <rdar://problem/7929157> & <rdar://problem/8104369>
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc struct A {
fA5*f4a2713aSLionel Sambuc   virtual int f() { return 1; }
6*f4a2713aSLionel Sambuc };
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc struct B {
fB9*f4a2713aSLionel Sambuc   virtual int f() { return 2; }
10*f4a2713aSLionel Sambuc };
11*f4a2713aSLionel Sambuc 
12*f4a2713aSLionel Sambuc struct C : A, B {
fC13*f4a2713aSLionel Sambuc   virtual int f() { return 3; }
14*f4a2713aSLionel Sambuc };
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc struct D : C {
fD17*f4a2713aSLionel Sambuc   virtual int f() { return 4; }
18*f4a2713aSLionel Sambuc };
19*f4a2713aSLionel Sambuc 
f(D * d)20*f4a2713aSLionel Sambuc static int f(D* d) {
21*f4a2713aSLionel Sambuc   B* b = d;
22*f4a2713aSLionel Sambuc   return b->f();
23*f4a2713aSLionel Sambuc };
24*f4a2713aSLionel Sambuc 
g()25*f4a2713aSLionel Sambuc int g() {
26*f4a2713aSLionel Sambuc   D d;
27*f4a2713aSLionel Sambuc   return f(&d);
28*f4a2713aSLionel Sambuc }
29*f4a2713aSLionel Sambuc 
30*f4a2713aSLionel Sambuc // Thunks should be marked as "linkonce ODR" not "weak".
31*f4a2713aSLionel Sambuc //
32*f4a2713aSLionel Sambuc // CHECK: define linkonce_odr i32 @_ZThn{{[48]}}_N1D1fEv
33*f4a2713aSLionel Sambuc // CHECK: define linkonce_odr i32 @_ZThn{{[48]}}_N1C1fEv
34