blob: b40b133a55412435966a58595f6f34475dd2c35b [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Fariborz Jahanian3da83eb2009-06-20 20:23:38 +00002
3struct X1 { // has no implicit default constructor
4 X1(int);
5};
6
John McCall7c2342d2010-03-10 11:27:22 +00007struct X2 : X1 { // expected-note 2 {{'X2' declared here}}
Fariborz Jahanian3da83eb2009-06-20 20:23:38 +00008 X2(int);
9};
10
John McCall7c2342d2010-03-10 11:27:22 +000011struct 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 Jahanian3da83eb2009-06-20 20:23:38 +000012};
Eli Friedman80c30da2009-11-09 19:20:36 +000013X3 x3; // expected-note {{first required here}}
Fariborz Jahanian3da83eb2009-06-20 20:23:38 +000014
15
Eli Friedman49c16da2009-11-09 01:05:47 +000016struct X4 { // expected-error {{must explicitly initialize the member 'x2'}} \
17 // expected-error {{must explicitly initialize the reference member 'rx2'}}
Fariborz Jahanian0c728f12009-10-08 22:15:49 +000018 X2 x2; // expected-note {{member is declared here}}
Fariborz Jahanian3da83eb2009-06-20 20:23:38 +000019 X2 & rx2; // expected-note {{declared at}}
20};
21
Eli Friedman80c30da2009-11-09 19:20:36 +000022X4 x4; // expected-note {{first required here}}
Fariborz Jahanian3da83eb2009-06-20 20:23:38 +000023
24
25struct Y1 { // has no implicit default constructor
26 Y1(int);
27};
28
29struct Y2 : Y1 {
30 Y2(int);
31 Y2();
32};
33
34struct Y3 : public Y2 {
35};
36Y3 y3;
37
38struct Y4 {
39 Y2 y2;
40};
41
42Y4 y4;
43
44// More tests
45
46
Eli Friedman49c16da2009-11-09 01:05:47 +000047struct Z1 { // expected-error {{must explicitly initialize the reference member 'z'}} \
48 // expected-error {{must explicitly initialize the const member 'c1'}}
Mike Stump1eb44332009-09-09 15:08:12 +000049 int& z; // expected-note {{declared at}}
50 const int c1; // expected-note {{declared at}}
51 volatile int v1;
Fariborz Jahanian3da83eb2009-06-20 20:23:38 +000052};
53
Eli Friedman80c30da2009-11-09 19:20:36 +000054Z1 z1; // expected-note {{first required here}}
Fariborz Jahanian3da83eb2009-06-20 20:23:38 +000055