Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Layout / aix-packed-bitfields.c
blob88f6b3fced80abc8e48da233a98912d60adcacb9
1 // RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fdump-record-layouts \
2 // RUN: -fsyntax-only -fxl-pragma-pack -x c %s | \
3 // RUN: FileCheck --check-prefixes=CHECK,32BIT %s
5 // RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fdump-record-layouts \
6 // RUN: -fsyntax-only -fxl-pragma-pack -x c++ %s | \
7 // RUN: FileCheck --check-prefixes=CHECK,32BIT %s
9 // RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -fdump-record-layouts \
10 // RUN: -fsyntax-only -fxl-pragma-pack -x c %s | \
11 // RUN: FileCheck --check-prefixes=CHECK,64BIT %s
13 // RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -fdump-record-layouts \
14 // RUN: -fsyntax-only -fxl-pragma-pack -x c++ %s | \
15 // RUN: FileCheck --check-prefixes=CHECK,64BIT %s
17 struct A {
18 int a1 : 30;
19 int a2 : 30;
20 int a3 : 4;
23 int a = sizeof(struct A);
25 // CHECK: *** Dumping AST Record Layout
26 // CHECK-NEXT: 0 | struct A
27 // CHECK-NEXT: 0:0-29 | int a1
28 // CHECK-NEXT: 4:0-29 | int a2
29 // CHECK-NEXT: 8:0-3 | int a3
30 // CHECK-NEXT: sizeof=12, {{(dsize=12, )?}}align=4, preferredalign=4
32 #pragma align(packed)
33 struct AlignPacked {
34 int a1 : 30;
35 int a2 : 30;
36 int a3 : 4;
38 #pragma align(reset)
40 int b = sizeof(struct AlignPacked);
42 // CHECK: *** Dumping AST Record Layout
43 // CHECK-NEXT: 0 | struct AlignPacked
44 // CHECK-NEXT: 0:0-29 | int a1
45 // CHECK-NEXT: 3:6-35 | int a2
46 // CHECK-NEXT: 7:4-7 | int a3
47 // CHECK-NEXT: sizeof=8, {{(dsize=8, )?}}align=1, preferredalign=1
49 #pragma pack(1)
50 struct Pack1 {
51 int a1 : 30;
52 int a2 : 30;
53 int a3 : 4;
55 #pragma pack(pop)
57 int c = sizeof(struct Pack1);
59 // CHECK: *** Dumping AST Record Layout
60 // CHECK-NEXT: 0 | struct Pack1
61 // CHECK-NEXT: 0:0-29 | int a1
62 // CHECK-NEXT: 3:6-35 | int a2
63 // CHECK-NEXT: 7:4-7 | int a3
64 // CHECK-NEXT: sizeof=8, {{(dsize=8, )?}}align=1, preferredalign=1
66 #pragma pack(2)
67 struct Pack2 {
68 int a1 : 30;
69 int a2 : 30;
70 int a3 : 4;
72 #pragma pack(pop)
74 int d = sizeof(struct Pack2);
76 // CHECK: *** Dumping AST Record Layout
77 // CHECK-NEXT: 0 | struct Pack2
78 // CHECK-NEXT: 0:0-29 | int a1
79 // CHECK-NEXT: 3:6-35 | int a2
80 // CHECK-NEXT: 7:4-7 | int a3
81 // CHECK-NEXT: sizeof=8, {{(dsize=8, )?}}align=2, preferredalign=2
83 struct __attribute__((packed)) PackedAttr {
84 char f1;
85 int : 0;
86 short : 3;
87 char f4 : 2;
90 int e = sizeof(struct PackedAttr);
91 // CHECK: *** Dumping AST Record Layout
92 // CHECK-NEXT: 0 | struct PackedAttr
93 // CHECK-NEXT: 0 | char f1
94 // CHECK-NEXT: 4:- | int
95 // CHECK-NEXT: 4:0-2 | short
96 // CHECK-NEXT: 4:3-4 | char f4
97 // CHECK-NEXT: sizeof=5, {{(dsize=5, )?}}align=1, preferredalign=1
99 #pragma pack(2)
100 struct __attribute__((packed)) PackedAttrAndPragma {
101 char f1;
102 long long : 0;
104 #pragma pack(pop)
106 int f = sizeof(struct PackedAttrAndPragma);
107 // CHECK: *** Dumping AST Record Layout
108 // CHECK-NEXT: 0 | struct PackedAttrAndPragma
109 // CHECK-NEXT: 0 | char f1
110 // 32BIT-NEXT: 4:- | long long
111 // 32BIT-NEXT: sizeof=4, {{(dsize=4, )?}}align=1, preferredalign=1
112 // 64BIT-NEXT: 8:- | long long
113 // 64BIT-NEXT: sizeof=8, {{(dsize=8, )?}}align=1, preferredalign=1