1 // RUN: %clang_cc1 -w -fdump-record-layouts-simple %s > %t.layouts
2 // RUN: %clang_cc1 -w -DPACKED= -DALIGNED16= -fdump-record-layouts-simple -foverride-record-layout=%t.layouts %s > %t.after
3 // RUN: diff %t.layouts %t.after
4 // RUN: FileCheck %s < %t.after
6 // If not explicitly disabled, set PACKED to the packed attribute.
8 # define PACKED __attribute__((packed))
11 // If not explicitly disabled, set ALIGNED16 to 16-byte alignment.
13 # define ALIGNED16 __attribute__((aligned(16)))
16 // CHECK: Type: struct X0
21 void use_X0(void) { struct X0 x0
; x0
.x
[5] = sizeof(struct X0
); };
23 // CHECK: Type: struct X1
29 void use_X1(void) { struct X1 x1
; x1
.x
[5] = sizeof(struct X1
); };
31 // CHECK: Type: struct X2
37 void use_X2(void) { struct X2 x2
; x2
.y
= sizeof(struct X2
); };
39 // CHECK: Type: struct X3
45 void use_X3(void) { struct X3 x3
; x3
.y
= sizeof(struct X3
); };
48 // CHECK: Type: struct X4
55 void use_X4(void) { struct X4 x4
; x4
.y
= sizeof(struct X4
); };
57 // CHECK: Type: struct X5
58 struct PACKED X5
{ double a
[19]; signed char b
; };
60 void use_X5(void) { struct X5 x5
; x5
.b
= sizeof(struct X5
); };
62 // CHECK: Type: struct X6
63 struct PACKED X6
{ long double a
; char b
; };
65 void use_X6(void) { struct X6 x6
; x6
.b
= sizeof(struct X6
); };
67 // CHECK: Type: struct X7
73 void use_X7(void) { struct X7 x7
; x7
.y
= x7
.x
= sizeof(struct X7
); }
75 // CHECK: Type: union X8
81 // CHECK: Type: struct X9
83 unsigned int x
[2] PACKED
;
85 unsigned int z PACKED
;
88 // CHECK: Type: struct X10
90 unsigned int x
[2] PACKED
;
91 unsigned int y PACKED
;
92 unsigned int z PACKED
;
95 // CHECK: Type: struct X11
102 // CHECK: Type: struct X12
107 // CHECK: Type: struct X13
113 // CHECK: Type: union X14
115 unsigned long long x
: 3;
118 // CHECK: Type: struct X15
121 unsigned y
: 28 PACKED
;
124 // CHECK: Type: struct X16
125 struct ALIGNED16 X16
{
131 void use_structs(void) {
133 typedef int X8array
[sizeof(union X8
)];
134 x8
.y
= sizeof(union X8
);
138 typedef int X9array
[sizeof(struct X9
)];
139 x9
.y
= sizeof(struct X9
);
142 typedef int X10array
[sizeof(struct X10
)];
143 x10
.y
= sizeof(struct X10
);
146 typedef int X11array
[sizeof(struct X11
)];
147 x11
.y
= sizeof(struct X11
);
150 x12
.x
= sizeof(struct X12
);
153 x13
.x
= sizeof(struct X13
);
156 x14
.x
= sizeof(union X14
);
159 x15
.x
= sizeof(struct X15
);
162 x16
.x
= sizeof(struct X16
);