aboutsummaryrefslogtreecommitdiff
path: root/test/SemaCXX/default-constructor-initializers.cpp
blob: 24c53839622c7ac35b2931006d983c82d36622f2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// RUN: clang-cc -fsyntax-only -verify %s

struct X1 { // has no implicit default constructor
   X1(int);
};

struct X2  : X1 {  // expected-note {{'struct X2' declared here}} \
                  //  expected-note {{'struct X2' declared here}}
   X2(int);
};

struct X3 : public X2 {
};
X3 x3;  // expected-error {{cannot define the implicit default constructor for 'struct X3', because member 'struct X2' does not have any default constructor}}


struct X4 {
  X2 x2; 
  X2 & rx2; // expected-note {{declared at}}
};

X4 x4; // expected-error {{cannot define the implicit default constructor for 'struct X4', because base class 'struct X2' does not have any default constructor}} \
       // expected-error {{cannot define the implicit default constructor for 'struct X4', because reference member rx2 cannot be default-initialized}}


struct Y1 { // has no implicit default constructor
   Y1(int);
};

struct Y2  : Y1 { 
   Y2(int);
   Y2();
};

struct Y3 : public Y2 {
};
Y3 y3; 

struct Y4 {
  Y2 y2; 
};

Y4 y4;

// More tests


struct Z1 {
        int& z; // expected-note {{declared at}}
  	const int c1; // expected-note {{declared at}}
  	volatile int v1;
};

Z1 z1;  // expected-error {{cannot define the implicit default constructor for 'struct Z1', because reference member z cannot be default-initialized}} \
        // expected-error {{cannot define the implicit default constructor for 'struct Z1', because const member c1 cannot be default-initialized}}