xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/virtual-bases.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin10 -mconstructor-aliases | FileCheck %s
2f4a2713aSLionel Sambuc 
3f4a2713aSLionel Sambuc struct A {
4f4a2713aSLionel Sambuc   A();
5f4a2713aSLionel Sambuc };
6f4a2713aSLionel Sambuc 
7f4a2713aSLionel Sambuc // CHECK: @_ZN1AC1Ev = alias {{.*}} @_ZN1AC2Ev
8f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_ZN1AC2Ev(%struct.A* %this) unnamed_addr
A()9f4a2713aSLionel Sambuc A::A() { }
10f4a2713aSLionel Sambuc 
11f4a2713aSLionel Sambuc struct B : virtual A {
12f4a2713aSLionel Sambuc   B();
13f4a2713aSLionel Sambuc };
14f4a2713aSLionel Sambuc 
15f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_ZN1BC2Ev(%struct.B* %this, i8** %vtt) unnamed_addr
16*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define void @_ZN1BC1Ev(%struct.B* %this) unnamed_addr
B()17f4a2713aSLionel Sambuc B::B() { }
18f4a2713aSLionel Sambuc 
19f4a2713aSLionel Sambuc struct C : virtual A {
20f4a2713aSLionel Sambuc   C(bool);
21f4a2713aSLionel Sambuc };
22f4a2713aSLionel Sambuc 
23f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_ZN1CC2Eb(%struct.C* %this, i8** %vtt, i1 zeroext) unnamed_addr
24*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define void @_ZN1CC1Eb(%struct.C* %this, i1 zeroext) unnamed_addr
C(bool)25f4a2713aSLionel Sambuc C::C(bool) { }
26f4a2713aSLionel Sambuc 
27f4a2713aSLionel Sambuc // PR6251
28f4a2713aSLionel Sambuc namespace PR6251 {
29f4a2713aSLionel Sambuc 
30f4a2713aSLionel Sambuc // Test that we don't call the A<char> constructor twice.
31f4a2713aSLionel Sambuc 
32f4a2713aSLionel Sambuc template<typename T>
33f4a2713aSLionel Sambuc struct A { A(); };
34f4a2713aSLionel Sambuc 
35f4a2713aSLionel Sambuc struct B : virtual A<char> { };
36f4a2713aSLionel Sambuc struct C : virtual A<char> { };
37f4a2713aSLionel Sambuc 
38f4a2713aSLionel Sambuc struct D : B, C  {
39f4a2713aSLionel Sambuc   D();
40f4a2713aSLionel Sambuc };
41f4a2713aSLionel Sambuc 
42f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_ZN6PR62511DC1Ev(%"struct.PR6251::D"* %this) unnamed_addr
43f4a2713aSLionel Sambuc // CHECK: call void @_ZN6PR62511AIcEC2Ev
44f4a2713aSLionel Sambuc // CHECK-NOT: call void @_ZN6PR62511AIcEC2Ev
45f4a2713aSLionel Sambuc // CHECK: ret void
D()46f4a2713aSLionel Sambuc D::D() { }
47f4a2713aSLionel Sambuc 
48f4a2713aSLionel Sambuc }
49