xref: /aosp_15_r20/external/clang/test/CodeGenCXX/microsoft-abi-vtables-ambiguous.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 %s -emit-llvm-only -triple=i386-pc-win32 -verify -DTEST1
2*67e74705SXin Li // RUN: %clang_cc1 %s -emit-llvm-only -triple=i386-pc-win32 -verify -DTEST2
3*67e74705SXin Li 
4*67e74705SXin Li #ifdef TEST1
5*67e74705SXin Li struct A {
6*67e74705SXin Li   virtual A *foo();  // in vftable slot #0.
7*67e74705SXin Li   virtual A *bar();  // in vftable slot #1.
8*67e74705SXin Li };
9*67e74705SXin Li 
10*67e74705SXin Li struct B : virtual A {
11*67e74705SXin Li   // appended to the A subobject's vftable in slot #2.
12*67e74705SXin Li   virtual B *foo(); // expected-note{{covariant thunk required by 'foo'}}
13*67e74705SXin Li };
14*67e74705SXin Li 
15*67e74705SXin Li struct C : virtual A {
16*67e74705SXin Li   // appended to the A subobject's vftable in slot #2.
17*67e74705SXin Li   virtual C *bar(); // expected-note{{covariant thunk required by 'bar'}}
18*67e74705SXin Li };
19*67e74705SXin Li 
20*67e74705SXin Li struct D : B, C { D(); }; // expected-error{{ambiguous vftable component}}
D()21*67e74705SXin Li D::D() {}
22*67e74705SXin Li #endif
23*67e74705SXin Li 
24*67e74705SXin Li #ifdef TEST2
25*67e74705SXin Li struct A {
26*67e74705SXin Li   virtual A *foo(); // in vftable slot #0
27*67e74705SXin Li };
28*67e74705SXin Li 
29*67e74705SXin Li struct B : virtual A {
30*67e74705SXin Li   // appended to the A subobject's vftable in slot #1.
31*67e74705SXin Li   virtual B *foo(); // expected-note{{covariant thunk required by 'foo'}}
32*67e74705SXin Li };
33*67e74705SXin Li 
34*67e74705SXin Li struct C : virtual A {
35*67e74705SXin Li   // appended to the A subobject's vftable in slot #1.
36*67e74705SXin Li   virtual C *foo(); // expected-note{{covariant thunk required by 'foo'}}
37*67e74705SXin Li };
38*67e74705SXin Li 
39*67e74705SXin Li struct D : B, C { // expected-error{{ambiguous vftable component}}
40*67e74705SXin Li   virtual D *foo();
41*67e74705SXin Li   D();
42*67e74705SXin Li };
D()43*67e74705SXin Li D::D() {}
44*67e74705SXin Li #endif
45