Fariborz Jahanian | 3da83eb | 2009-06-20 20:23:38 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s |
| 2 | |
| 3 | struct X1 { // has no implicit default constructor |
| 4 | X1(int); |
| 5 | }; |
| 6 | |
| 7 | struct X2 : X1 { // expected-note {{'struct X2' declared here}} \ |
| 8 | // expected-note {{'struct X2' declared here}} |
| 9 | X2(int); |
| 10 | }; |
| 11 | |
| 12 | struct X3 : public X2 { |
| 13 | }; |
Fariborz Jahanian | c1005ac | 2009-06-22 16:33:37 +0000 | [diff] [blame] | 14 | X3 x3; // expected-error {{cannot define the implicit default constructor for 'struct X3', because member 'struct X2' does not have any default constructor}} |
Fariborz Jahanian | 3da83eb | 2009-06-20 20:23:38 +0000 | [diff] [blame] | 15 | |
| 16 | |
| 17 | struct X4 { |
| 18 | X2 x2; |
| 19 | X2 & rx2; // expected-note {{declared at}} |
| 20 | }; |
| 21 | |
Fariborz Jahanian | c1005ac | 2009-06-22 16:33:37 +0000 | [diff] [blame] | 22 | X4 x4; // expected-error {{cannot define the implicit default constructor for 'struct X4', because base class 'struct X2' does not have any default constructor}} \ |
Anders Carlsson | 5eda816 | 2009-07-09 17:37:12 +0000 | [diff] [blame] | 23 | // expected-error {{cannot define the implicit default constructor for 'struct X4', because reference member 'rx2' cannot be default-initialized}} |
Fariborz Jahanian | 3da83eb | 2009-06-20 20:23:38 +0000 | [diff] [blame] | 24 | |
| 25 | |
| 26 | struct Y1 { // has no implicit default constructor |
| 27 | Y1(int); |
| 28 | }; |
| 29 | |
| 30 | struct Y2 : Y1 { |
| 31 | Y2(int); |
| 32 | Y2(); |
| 33 | }; |
| 34 | |
| 35 | struct Y3 : public Y2 { |
| 36 | }; |
| 37 | Y3 y3; |
| 38 | |
| 39 | struct Y4 { |
| 40 | Y2 y2; |
| 41 | }; |
| 42 | |
| 43 | Y4 y4; |
| 44 | |
| 45 | // More tests |
| 46 | |
| 47 | |
| 48 | struct Z1 { |
| 49 | int& z; // expected-note {{declared at}} |
| 50 | const int c1; // expected-note {{declared at}} |
| 51 | volatile int v1; |
| 52 | }; |
| 53 | |
Anders Carlsson | 5eda816 | 2009-07-09 17:37:12 +0000 | [diff] [blame] | 54 | Z1 z1; // expected-error {{cannot define the implicit default constructor for 'struct Z1', because reference member 'z' cannot be default-initialized}} \ |
| 55 | // expected-error {{cannot define the implicit default constructor for 'struct Z1', because const member 'c1' cannot be default-initialized}} |
Fariborz Jahanian | 3da83eb | 2009-06-20 20:23:38 +0000 | [diff] [blame] | 56 | |