Anders Carlsson | 74cbe22 | 2009-07-19 00:18:47 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -triple x86_64-unknown-unknown %s -fsyntax-only -verify |
| 2 | |
| 3 | #define SA(n, p) int a##n[(p) ? 1 : -1] |
| 4 | |
| 5 | struct A { |
| 6 | int a; |
| 7 | char b; |
| 8 | }; |
| 9 | |
| 10 | SA(0, sizeof(A) == 8); |
| 11 | |
| 12 | struct B : A { |
| 13 | char c; |
| 14 | }; |
| 15 | |
| 16 | SA(1, sizeof(B) == 12); |
| 17 | |
| 18 | struct C { |
| 19 | // Make fields private so C won't be a POD type. |
| 20 | private: |
| 21 | int a; |
| 22 | char b; |
| 23 | }; |
| 24 | |
| 25 | SA(2, sizeof(C) == 8); |
| 26 | |
| 27 | struct D : C { |
| 28 | char c; |
| 29 | }; |
| 30 | |
| 31 | SA(3, sizeof(D) == 8); |
Anders Carlsson | 227aad5 | 2009-07-28 17:14:18 +0000 | [diff] [blame] | 32 | |
| 33 | struct __attribute__((packed)) E { |
| 34 | char b; |
| 35 | int a; |
| 36 | }; |
| 37 | |
| 38 | SA(4, sizeof(E) == 5); |
| 39 | |
| 40 | struct __attribute__((packed)) F : E { |
| 41 | char d; |
| 42 | }; |
| 43 | |
| 44 | SA(5, sizeof(F) == 6); |
Anders Carlsson | b237fd6 | 2009-09-17 04:42:56 +0000 | [diff] [blame] | 45 | |
| 46 | struct G { G(); }; |
| 47 | struct H : G { }; |
| 48 | |
| 49 | SA(6, sizeof(H) == 1); |