Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Fariborz Jahanian | 3da83eb | 2009-06-20 20:23:38 +0000 | [diff] [blame] | 2 | |
| 3 | struct X1 { // has no implicit default constructor |
| 4 | X1(int); |
| 5 | }; |
| 6 | |
John McCall | 7c2342d | 2010-03-10 11:27:22 +0000 | [diff] [blame^] | 7 | struct X2 : X1 { // expected-note 2 {{'X2' declared here}} |
Fariborz Jahanian | 3da83eb | 2009-06-20 20:23:38 +0000 | [diff] [blame] | 8 | X2(int); |
| 9 | }; |
| 10 | |
John McCall | 7c2342d | 2010-03-10 11:27:22 +0000 | [diff] [blame^] | 11 | struct X3 : public X2 { // expected-error {{implicit default constructor for 'X3' must explicitly initialize the base class 'X2' which does not have a default constructor}} |
Fariborz Jahanian | 3da83eb | 2009-06-20 20:23:38 +0000 | [diff] [blame] | 12 | }; |
Eli Friedman | 80c30da | 2009-11-09 19:20:36 +0000 | [diff] [blame] | 13 | X3 x3; // expected-note {{first required here}} |
Fariborz Jahanian | 3da83eb | 2009-06-20 20:23:38 +0000 | [diff] [blame] | 14 | |
| 15 | |
Eli Friedman | 49c16da | 2009-11-09 01:05:47 +0000 | [diff] [blame] | 16 | struct X4 { // expected-error {{must explicitly initialize the member 'x2'}} \ |
| 17 | // expected-error {{must explicitly initialize the reference member 'rx2'}} |
Fariborz Jahanian | 0c728f1 | 2009-10-08 22:15:49 +0000 | [diff] [blame] | 18 | X2 x2; // expected-note {{member is declared here}} |
Fariborz Jahanian | 3da83eb | 2009-06-20 20:23:38 +0000 | [diff] [blame] | 19 | X2 & rx2; // expected-note {{declared at}} |
| 20 | }; |
| 21 | |
Eli Friedman | 80c30da | 2009-11-09 19:20:36 +0000 | [diff] [blame] | 22 | X4 x4; // expected-note {{first required here}} |
Fariborz Jahanian | 3da83eb | 2009-06-20 20:23:38 +0000 | [diff] [blame] | 23 | |
| 24 | |
| 25 | struct Y1 { // has no implicit default constructor |
| 26 | Y1(int); |
| 27 | }; |
| 28 | |
| 29 | struct Y2 : Y1 { |
| 30 | Y2(int); |
| 31 | Y2(); |
| 32 | }; |
| 33 | |
| 34 | struct Y3 : public Y2 { |
| 35 | }; |
| 36 | Y3 y3; |
| 37 | |
| 38 | struct Y4 { |
| 39 | Y2 y2; |
| 40 | }; |
| 41 | |
| 42 | Y4 y4; |
| 43 | |
| 44 | // More tests |
| 45 | |
| 46 | |
Eli Friedman | 49c16da | 2009-11-09 01:05:47 +0000 | [diff] [blame] | 47 | struct Z1 { // expected-error {{must explicitly initialize the reference member 'z'}} \ |
| 48 | // expected-error {{must explicitly initialize the const member 'c1'}} |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 49 | int& z; // expected-note {{declared at}} |
| 50 | const int c1; // expected-note {{declared at}} |
| 51 | volatile int v1; |
Fariborz Jahanian | 3da83eb | 2009-06-20 20:23:38 +0000 | [diff] [blame] | 52 | }; |
| 53 | |
Eli Friedman | 80c30da | 2009-11-09 19:20:36 +0000 | [diff] [blame] | 54 | Z1 z1; // expected-note {{first required here}} |
Fariborz Jahanian | 3da83eb | 2009-06-20 20:23:38 +0000 | [diff] [blame] | 55 | |