xref: /llvm-project/clang/test/CXX/special/class.init/class.inhctor.init/p2.cpp (revision 5179eb78210a2ad01a18c37b75048ccfe78414ac)
1*5179eb78SRichard Smith // RUN: %clang_cc1 -std=c++11 -verify %s
2*5179eb78SRichard Smith 
3*5179eb78SRichard Smith namespace std_example {
4*5179eb78SRichard Smith   struct A { A(int); };
5*5179eb78SRichard Smith   struct B : A { using A::A; };
6*5179eb78SRichard Smith 
7*5179eb78SRichard Smith   struct C1 : B { using B::B; };
8*5179eb78SRichard Smith   struct C2 : B { using B::B; };
9*5179eb78SRichard Smith 
10*5179eb78SRichard Smith   struct D1 : C1, C2 {
11*5179eb78SRichard Smith     using C1::C1; // expected-note {{inherited from base class 'C1' here}}
12*5179eb78SRichard Smith     using C2::C2; // expected-note {{inherited from base class 'C2' here}}
13*5179eb78SRichard Smith   };
14*5179eb78SRichard Smith 
15*5179eb78SRichard Smith   struct V1 : virtual B { using B::B; };
16*5179eb78SRichard Smith   struct V2 : virtual B { using B::B; };
17*5179eb78SRichard Smith 
18*5179eb78SRichard Smith   struct D2 : V1, V2 {
19*5179eb78SRichard Smith     using V1::V1;
20*5179eb78SRichard Smith     using V2::V2;
21*5179eb78SRichard Smith   };
22*5179eb78SRichard Smith 
23*5179eb78SRichard Smith   D1 d1(0); // expected-error {{constructor of 'A' inherited from multiple base class subobjects}}
24*5179eb78SRichard Smith   D2 d2(0); // OK: initializes virtual B base class, which initializes the A base class
25*5179eb78SRichard Smith             // then initializes the V1 and V2 base classes as if by a defaulted default constructor
26*5179eb78SRichard Smith 
27*5179eb78SRichard Smith   struct M { M(); M(int); };
28*5179eb78SRichard Smith   struct N : M { using M::M; };
29*5179eb78SRichard Smith   struct O : M {};
30*5179eb78SRichard Smith   struct P : N, O { using N::N; using O::O; };
31*5179eb78SRichard Smith   P p(0); // OK: use M(0) to initialize N's base class,
32*5179eb78SRichard Smith           // use M() to initialize O's base class
33*5179eb78SRichard Smith }
34