1 // RUN: %clang_cc1 -fdump-record-layouts-simple %s 2> %t.layouts
2 // RUN: %clang_cc1 -fdump-record-layouts-simple %s > %t.before 2>&1
3 // RUN: %clang_cc1 -DPACKED= -DALIGNED16= -fdump-record-layouts-simple -foverride-record-layout=%t.layouts %s > %t.after 2>&1
4 // RUN: diff %t.before %t.after
5 // RUN: FileCheck %s < %t.after
6 
7 // If not explicitly disabled, set PACKED to the packed attribute.
8 #ifndef PACKED
9 #  define PACKED __attribute__((packed))
10 #endif
11 
12 struct Empty1 { };
13 struct Empty2 { };
14 
15 // CHECK: Type: struct X0
16 struct X0 : public Empty1 {
17   int x[6] PACKED;
18 };
19 
20 // CHECK: Type: struct X1
21 struct X1 : public X0, public Empty2 {
22   char x[13];
23   struct X0 y;
24 } PACKED;
25 
26 // CHECK: Type: struct X2
27 struct PACKED X2 :  public X1, public X0, public Empty1 {
28   short x;
29   int y;
30 };
31 
32 // CHECK: Type: struct X3
33 struct PACKED X3 : virtual public X1, public X0 {
34   short x;
35   int y;
36 };
37 
38 void use_structs() {
39   struct X0 x0;
40   x0.x[5] = sizeof(struct X0);
41 
42   struct X1 x1;
43   x1.x[5] = sizeof(struct X1);
44 
45   struct X2 x2;
46   x2.y = sizeof(struct X2);
47 
48   struct X3 x3;
49   x3.y = sizeof(struct X3);
50 }
51