Daniel Dunbar | 8fbe78f | 2009-12-15 20:14:24 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Fariborz Jahanian | 1c9d5d9 | 2009-06-20 20:23:38 +0000 | [diff] [blame] | 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 | |
Eli Friedman | d7686ef | 2009-11-09 01:05:47 +0000 | [diff] [blame] | 12 | struct X3 : public X2 { // expected-error {{must explicitly initialize the base class 'struct X2'}} |
Fariborz Jahanian | 1c9d5d9 | 2009-06-20 20:23:38 +0000 | [diff] [blame] | 13 | }; |
Eli Friedman | 9cf6b59 | 2009-11-09 19:20:36 +0000 | [diff] [blame] | 14 | X3 x3; // expected-note {{first required here}} |
Fariborz Jahanian | 1c9d5d9 | 2009-06-20 20:23:38 +0000 | [diff] [blame] | 15 | |
| 16 | |
Eli Friedman | d7686ef | 2009-11-09 01:05:47 +0000 | [diff] [blame] | 17 | struct X4 { // expected-error {{must explicitly initialize the member 'x2'}} \ |
| 18 | // expected-error {{must explicitly initialize the reference member 'rx2'}} |
Fariborz Jahanian | 8ae5b0a | 2009-10-08 22:15:49 +0000 | [diff] [blame] | 19 | X2 x2; // expected-note {{member is declared here}} |
Fariborz Jahanian | 1c9d5d9 | 2009-06-20 20:23:38 +0000 | [diff] [blame] | 20 | X2 & rx2; // expected-note {{declared at}} |
| 21 | }; |
| 22 | |
Eli Friedman | 9cf6b59 | 2009-11-09 19:20:36 +0000 | [diff] [blame] | 23 | X4 x4; // expected-note {{first required here}} |
Fariborz Jahanian | 1c9d5d9 | 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 | |
Eli Friedman | d7686ef | 2009-11-09 01:05:47 +0000 | [diff] [blame] | 48 | struct Z1 { // expected-error {{must explicitly initialize the reference member 'z'}} \ |
| 49 | // expected-error {{must explicitly initialize the const member 'c1'}} |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 50 | int& z; // expected-note {{declared at}} |
| 51 | const int c1; // expected-note {{declared at}} |
| 52 | volatile int v1; |
Fariborz Jahanian | 1c9d5d9 | 2009-06-20 20:23:38 +0000 | [diff] [blame] | 53 | }; |
| 54 | |
Eli Friedman | 9cf6b59 | 2009-11-09 19:20:36 +0000 | [diff] [blame] | 55 | Z1 z1; // expected-note {{first required here}} |
Fariborz Jahanian | 1c9d5d9 | 2009-06-20 20:23:38 +0000 | [diff] [blame] | 56 | |