blob: bfce588b570a80303a4d7760965a623dfd335df3 [file] [log] [blame]
Fariborz Jahanianeb96e122009-07-09 19:59:47 +00001// RUN: clang-cc -fsyntax-only -Wreorder -verify %s
2
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}}
Fariborz Jahanian40c072f2009-07-10 20:13:23 +000012 BB1(), // expected-note {{base 'struct BB1'}} \
13 // expected-warning {{base class 'struct BB1' will be initialized after}}
14 BB() {} // expected-note {{base 'struct 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 {
47 D() : A(), V() { } // expected-warning {{base class 'struct A' will be initialized after}} \
48 // expected-note {{base 'struct V'}}
49};
50
51
52struct E : public A, public B, private virtual V {
53 E() : A(), V() { } // expected-warning {{base class 'struct A' will be initialized after}} \
54 // expected-note {{base 'struct V'}}
55};
56
57
58struct A1 {
59 A1();
60};
61
62struct B1 {
63 B1();
64};
65
66struct F : public A1, public B1, private virtual V {
Mike Stump1eb44332009-09-09 15:08:12 +000067 F() : A1(), V() { } // expected-warning {{base class 'struct A1' will be initialized after}} \
68 // expected-note {{base 'struct V'}}
Fariborz Jahanian40c072f2009-07-10 20:13:23 +000069};
70
71struct X : public virtual A, virtual V, public virtual B {
Mike Stump1eb44332009-09-09 15:08:12 +000072 X(): A(), V(), B() {} // expected-warning {{base class 'struct A' will be initialized after}} \
73 // expected-note {{base 'struct 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};