blob: f4191565dfdbcfda4cb2af3728995cb6c2d12438 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -Wreorder -verify %s
Fariborz Jahanianeb96e122009-07-09 19:59:47 +00002
Fariborz Jahanian40c072f2009-07-10 20:13:23 +00003struct BB {};
Fariborz Jahanianeb96e122009-07-09 19:59:47 +00004
Fariborz Jahanian40c072f2009-07-10 20:13:23 +00005struct BB1 {};
Fariborz Jahanianeb96e122009-07-09 19:59:47 +00006
Fariborz Jahanian40c072f2009-07-10 20:13:23 +00007class complex : public BB, BB1 {
Fariborz Jahanianeb96e122009-07-09 19:59:47 +00008public:
9 complex() : s2(1), // expected-warning {{member 's2' will be initialized after}}
10 s1(1) , // expected-note {{field s1}}
11 s3(3), // expected-warning {{member 's3' will be initialized after}}
John McCall7c2342d2010-03-10 11:27:22 +000012 BB1(), // expected-note {{base 'BB1'}} \
13 // expected-warning {{base class 'BB1' will be initialized after}}
14 BB() {} // expected-note {{base 'BB'}}
Fariborz Jahanianeb96e122009-07-09 19:59:47 +000015 int s1;
16 int s2;
17 int s3;
18};
Fariborz Jahanian40c072f2009-07-10 20:13:23 +000019
20
21// testing virtual bases.
22
23
24struct V {
25 V();
26};
27
28struct A : public virtual V {
29 A();
30};
31
32struct B : public virtual V {
33 B();
34};
35
36struct Diamond : public A, public B {
37 Diamond() : A(), B() {}
38};
39
40
41struct C : public A, public B, private virtual V {
42 C() { }
43};
44
45
46struct D : public A, public B {
John McCall7c2342d2010-03-10 11:27:22 +000047 D() : A(), V() { } // expected-warning {{base class 'A' will be initialized after}} \
48 // expected-note {{base 'V'}}
Fariborz Jahanian40c072f2009-07-10 20:13:23 +000049};
50
51
52struct E : public A, public B, private virtual V {
John McCall7c2342d2010-03-10 11:27:22 +000053 E() : A(), V() { } // expected-warning {{base class 'A' will be initialized after}} \
54 // expected-note {{base 'V'}}
Fariborz Jahanian40c072f2009-07-10 20:13:23 +000055};
56
57
58struct A1 {
59 A1();
60};
61
62struct B1 {
63 B1();
64};
65
66struct F : public A1, public B1, private virtual V {
John McCall7c2342d2010-03-10 11:27:22 +000067 F() : A1(), V() { } // expected-warning {{base class 'A1' will be initialized after}} \
68 // expected-note {{base 'V'}}
Fariborz Jahanian40c072f2009-07-10 20:13:23 +000069};
70
71struct X : public virtual A, virtual V, public virtual B {
John McCall7c2342d2010-03-10 11:27:22 +000072 X(): A(), V(), B() {} // expected-warning {{base class 'A' will be initialized after}} \
73 // expected-note {{base 'V'}}
Fariborz Jahanian40c072f2009-07-10 20:13:23 +000074};
75
Eli Friedman6347f422009-07-21 19:28:10 +000076class Anon {
77 int c; union {int a,b;}; int d;
78 Anon() : c(10), b(1), d(2) {}
79};
80class Anon2 {
81 int c; union {int a,b;}; int d;
82 Anon2() : c(2),
83 d(10), // expected-warning {{member 'd' will be initialized after}}
84 b(1) {} // expected-note {{field b}}
85};
86class Anon3 {
87 union {int a,b;};
88 Anon3() : b(1) {}
89};
Anders Carlsson6f6de732010-03-29 05:13:12 +000090
91namespace T1 {
92
93struct S1 { };
94struct S2: virtual S1 { };
95struct S3 { };
96
97struct S4: virtual S3, S2 {
98 S4() : S2(), // expected-warning {{base class 'T1::S2' will be initialized after}}
99 S3() { }; // expected-note {{base 'T1::S3'}}
100};
101}