1 // RUN: %clang_cc1 -std=c++11 -verify %s
3 namespace std_example
{
14 struct D1
: B1
{ // expected-note {{no default constructor}}
15 using B1::B1
; // inherits B1(int, ...)
21 D1
d(2, 3, 4); // OK: B1 is initialized by calling B1(2, 3, 4),
22 // then d.x is default-initialized (no initialization is performed),
23 // then d.y is initialized by calling get()
24 D1 e
; // expected-error {{implicitly-deleted}}
29 B1 b
; // expected-note {{constructor inherited by 'D2' is implicitly deleted because field 'b' has no default constructor}}
32 D2
f(1.0); // expected-error {{constructor inherited by 'D2' from base class 'B2' is implicitly deleted}}
37 struct X
: virtual W
{
44 struct Z
: Y
, virtual W
{
47 Z
z(0); // OK: initialization of Y does not invoke default constructor of X
49 template <class T
> struct Log
: T
{
50 using T::T
; // inherits all constructors from class T
60 struct A
: virtual V
{
61 A() = delete; // expected-note 2{{deleted here}} expected-note {{deleted}}
64 struct B
: virtual V
{ // expected-note {{no default constructor}}
65 B() = delete; // expected-note 2{{deleted here}}
69 struct C
: B
{ // expected-note {{deleted default constructor}}
72 struct D
: A
, C
{ // expected-note {{deleted default constructor}} expected-note {{deleted corresponding constructor}}
77 A a0
; // expected-error {{deleted}}
79 B b0
; // expected-error {{deleted}}
82 C c0
; // expected-error {{deleted}}
84 C
c2(0, 0); // expected-error {{deleted}}
85 D d0
; // expected-error {{deleted}}
87 D
d2(0, 0); // expected-error {{deleted}}
90 namespace vbase_of_vbase
{
92 struct W
: virtual V
{ using V::V
; };
93 struct X
: virtual W
, virtual V
{ using W::W
; };
97 namespace constexpr_init_order
{
104 struct B
: A
{ B(); using A::A
; int b
= 2; };
106 // Construct a situation where a value can be observed to change during
107 // constant evaluation in C++11: value-initialization of Wrap2 performs
108 // zero-initialization and then calls the constructor.
109 struct Wrap1
: B
{ constexpr Wrap1(); };
110 struct Wrap2
: Wrap1
{};
112 extern const Wrap2 b
;
115 constexpr Param(int c
) : n(4 * b
.a
+ b
.b
+ c
) {}
119 constexpr A::A(Param p
) : a(p
.n
) {}
121 constexpr Wrap1::Wrap1() : B(1) {}
123 constexpr Wrap2 b
= {};
125 static_assert(b
.a
== 1, "p should be initialized before B() is executed");
126 static_assert(c
.a
== 7, "b not initialized properly");
129 namespace default_args
{
130 // We work around a defect in P0136R1 where it would reject reasonable
131 // code like the following:
135 struct Derived
: Base
{
139 // FIXME: Once a fix is standardized, implement it.