1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
5 struct X1
{ // has no implicit default constructor
10 #if __cplusplus <= 199711L
11 // expected-note@-2 2 {{'X2' declared here}}
17 struct X3
: public X2
{
18 #if __cplusplus <= 199711L
19 // expected-error@-2 {{implicit default constructor for 'X3' must explicitly initialize the base class 'X2' which does not have a default constructor}}
21 // expected-note@-4 {{default constructor of 'X3' is implicitly deleted because base class 'X2' has no default constructor}}
26 #if __cplusplus <= 199711L
27 // expected-note@-2 {{first required here}}
29 // expected-error@-4 {{call to implicitly-deleted default constructor of 'X3'}}
33 #if __cplusplus <= 199711L
34 // expected-error@-2 {{must explicitly initialize the member 'x2'}}
35 // expected-error@-3 {{must explicitly initialize the reference member 'rx2'}}
39 #if __cplusplus <= 199711L
40 // expected-note@-2 {{member is declared here}}
42 // expected-note@-4 {{default constructor of 'X4' is implicitly deleted because field 'x2' has no default constructor}}
46 #if __cplusplus <= 199711L
47 // expected-note@-2 {{declared here}}
52 #if __cplusplus <= 199711L
53 // expected-note@-2 {{first required here}}
55 // expected-error@-4 {{call to implicitly-deleted default constructor of 'X4'}}
58 struct Y1
{ // has no implicit default constructor
67 struct Y3
: public Y2
{
80 #if __cplusplus <= 199711L
81 // expected-error@-2 {{must explicitly initialize the reference member 'z'}}
82 // expected-error@-3 {{must explicitly initialize the const member 'c1'}}
86 #if __cplusplus <= 199711L
87 // expected-note@-2 {{declared here}}
89 // expected-note@-4 {{default constructor of 'Z1' is implicitly deleted because field 'z' of reference type 'int &' would not be initialized}}
93 #if __cplusplus <= 199711L
94 // expected-note@-2 {{declared here}}
99 // Test default initialization which *requires* a constructor call for non-POD.
101 #if __cplusplus <= 199711L
102 // expected-note@-2 {{first required here}}
104 // expected-error@-4 {{call to implicitly-deleted default constructor of 'Z1'}}
107 // Ensure that value initialization doesn't use trivial implicit constructors.
109 // Note that this is also non-POD to ensure we don't just special case PODs.
110 struct S
{ const int x
; ~S(); };
111 const S arr
[2] = { { 42 } };