blob: 56f41bfbdb936a042186b84597cbe4bc36e05820 [file] [log] [blame]
Anders Carlsson74cbe222009-07-19 00:18:47 +00001// 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
5struct A {
6 int a;
7 char b;
8};
9
10SA(0, sizeof(A) == 8);
11
12struct B : A {
13 char c;
14};
15
16SA(1, sizeof(B) == 12);
17
18struct C {
19// Make fields private so C won't be a POD type.
20private:
21 int a;
22 char b;
23};
24
25SA(2, sizeof(C) == 8);
26
27struct D : C {
28 char c;
29};
30
31SA(3, sizeof(D) == 8);
Anders Carlsson227aad52009-07-28 17:14:18 +000032
33struct __attribute__((packed)) E {
34 char b;
35 int a;
36};
37
38SA(4, sizeof(E) == 5);
39
40struct __attribute__((packed)) F : E {
41 char d;
42};
43
44SA(5, sizeof(F) == 6);
Anders Carlssonb237fd62009-09-17 04:42:56 +000045
46struct G { G(); };
47struct H : G { };
48
49SA(6, sizeof(H) == 1);