Fariborz Jahanian | eb96e12 | 2009-07-09 19:59:47 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -Wreorder -verify %s |
| 2 | |
Fariborz Jahanian | 40c072f | 2009-07-10 20:13:23 +0000 | [diff] [blame] | 3 | struct BB {}; |
Fariborz Jahanian | eb96e12 | 2009-07-09 19:59:47 +0000 | [diff] [blame] | 4 | |
Fariborz Jahanian | 40c072f | 2009-07-10 20:13:23 +0000 | [diff] [blame] | 5 | struct BB1 {}; |
Fariborz Jahanian | eb96e12 | 2009-07-09 19:59:47 +0000 | [diff] [blame] | 6 | |
Fariborz Jahanian | 40c072f | 2009-07-10 20:13:23 +0000 | [diff] [blame] | 7 | class complex : public BB, BB1 { |
Fariborz Jahanian | eb96e12 | 2009-07-09 19:59:47 +0000 | [diff] [blame] | 8 | public: |
| 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 Jahanian | 40c072f | 2009-07-10 20:13:23 +0000 | [diff] [blame] | 12 | 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 Jahanian | eb96e12 | 2009-07-09 19:59:47 +0000 | [diff] [blame] | 15 | int s1; |
| 16 | int s2; |
| 17 | int s3; |
| 18 | }; |
Fariborz Jahanian | 40c072f | 2009-07-10 20:13:23 +0000 | [diff] [blame] | 19 | |
| 20 | |
| 21 | // testing virtual bases. |
| 22 | |
| 23 | |
| 24 | struct V { |
| 25 | V(); |
| 26 | }; |
| 27 | |
| 28 | struct A : public virtual V { |
| 29 | A(); |
| 30 | }; |
| 31 | |
| 32 | struct B : public virtual V { |
| 33 | B(); |
| 34 | }; |
| 35 | |
| 36 | struct Diamond : public A, public B { |
| 37 | Diamond() : A(), B() {} |
| 38 | }; |
| 39 | |
| 40 | |
| 41 | struct C : public A, public B, private virtual V { |
| 42 | C() { } |
| 43 | }; |
| 44 | |
| 45 | |
| 46 | struct 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 | |
| 52 | struct 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 | |
| 58 | struct A1 { |
| 59 | A1(); |
| 60 | }; |
| 61 | |
| 62 | struct B1 { |
| 63 | B1(); |
| 64 | }; |
| 65 | |
| 66 | struct F : public A1, public B1, private virtual V { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 67 | F() : A1(), V() { } // expected-warning {{base class 'struct A1' will be initialized after}} \ |
| 68 | // expected-note {{base 'struct V'}} |
Fariborz Jahanian | 40c072f | 2009-07-10 20:13:23 +0000 | [diff] [blame] | 69 | }; |
| 70 | |
| 71 | struct X : public virtual A, virtual V, public virtual B { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 72 | X(): A(), V(), B() {} // expected-warning {{base class 'struct A' will be initialized after}} \ |
| 73 | // expected-note {{base 'struct V'}} |
Fariborz Jahanian | 40c072f | 2009-07-10 20:13:23 +0000 | [diff] [blame] | 74 | }; |
| 75 | |
Eli Friedman | 6347f42 | 2009-07-21 19:28:10 +0000 | [diff] [blame] | 76 | class Anon { |
| 77 | int c; union {int a,b;}; int d; |
| 78 | Anon() : c(10), b(1), d(2) {} |
| 79 | }; |
| 80 | class 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 | }; |
| 86 | class Anon3 { |
| 87 | union {int a,b;}; |
| 88 | Anon3() : b(1) {} |
| 89 | }; |