llvm-project
146 строк · 4.1 Кб
1// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fdump-record-layouts \
2// RUN: -fxl-pragma-pack -fsyntax-only %s | \
3// RUN: FileCheck %s
4
5// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -fdump-record-layouts \
6// RUN: -fxl-pragma-pack -fsyntax-only %s | \
7// RUN: FileCheck %s
8
9namespace test1 {10#pragma align(natural)11struct A {12int i1;13};14
15struct B {16double d1;17};18#pragma align(reset)19
20struct C : A, B {21double d2;22};23
24int a = sizeof(C);25
26// CHECK: *** Dumping AST Record Layout
27// CHECK-NEXT: 0 | struct test1::A
28// CHECK-NEXT: 0 | int i1
29// CHECK-NEXT: | [sizeof=4, dsize=4, align=4, preferredalign=4,
30// CHECK-NEXT: | nvsize=4, nvalign=4, preferrednvalign=4]
31
32// CHECK: *** Dumping AST Record Layout
33// CHECK-NEXT: 0 | struct test1::B
34// CHECK-NEXT: 0 | double d1
35// CHECK-NEXT: | [sizeof=8, dsize=8, align=4, preferredalign=8,
36// CHECK-NEXT: | nvsize=8, nvalign=4, preferrednvalign=8]
37
38// CHECK: *** Dumping AST Record Layout
39// CHECK-NEXT: 0 | struct test1::C
40// CHECK-NEXT: 0 | struct test1::A (base)
41// CHECK-NEXT: 0 | int i1
42// CHECK-NEXT: 4 | struct test1::B (base)
43// CHECK-NEXT: 4 | double d1
44// CHECK-NEXT: 12 | double d2
45// CHECK-NEXT: | [sizeof=20, dsize=20, align=4, preferredalign=4,
46// CHECK-NEXT: | nvsize=20, nvalign=4, preferrednvalign=4]
47
48} // namespace test149
50namespace test2 {51struct A {52int i1;53double d;54};55
56#pragma align(natural)57struct B : A {58int i2;59};60#pragma align(reset)61
62int b = sizeof(B);63
64// CHECK: *** Dumping AST Record Layout
65// CHECK-NEXT: 0 | struct test2::A
66// CHECK-NEXT: 0 | int i1
67// CHECK-NEXT: 4 | double d
68// CHECK-NEXT: | [sizeof=12, dsize=12, align=4, preferredalign=4,
69// CHECK-NEXT: | nvsize=12, nvalign=4, preferrednvalign=4]
70
71// CHECK: *** Dumping AST Record Layout
72// CHECK-NEXT: 0 | struct test2::B
73// CHECK-NEXT: 0 | struct test2::A (base)
74// CHECK-NEXT: 0 | int i1
75// CHECK-NEXT: 4 | double d
76// CHECK-NEXT: 12 | int i2
77// CHECK-NEXT: | [sizeof=16, dsize=16, align=4, preferredalign=4,
78// CHECK-NEXT: | nvsize=16, nvalign=4, preferrednvalign=4]
79
80} // namespace test281
82namespace test3 {83#pragma align(natural)84struct A {85int i1;86double d;87};88#pragma align(reset)89
90struct B {91struct A a;92int i2;93};94
95int c = sizeof(B);96
97// CHECK: *** Dumping AST Record Layout
98// CHECK-NEXT: 0 | struct test3::A
99// CHECK-NEXT: 0 | int i1
100// CHECK-NEXT: 8 | double d
101// CHECK-NEXT: | [sizeof=16, dsize=16, align=4, preferredalign=8,
102// CHECK-NEXT: | nvsize=16, nvalign=4, preferrednvalign=8]
103
104// CHECK: *** Dumping AST Record Layout
105// CHECK-NEXT: 0 | struct test3::B
106// CHECK-NEXT: 0 | struct test3::A a
107// CHECK-NEXT: 0 | int i1
108// CHECK-NEXT: 8 | double d
109// CHECK-NEXT: 16 | int i2
110// CHECK-NEXT: | [sizeof=24, dsize=24, align=4, preferredalign=8,
111// CHECK-NEXT: | nvsize=24, nvalign=4, preferrednvalign=8]
112
113} // namespace test3114
115namespace test4 {116struct A {117int i1;118double d;119};120
121#pragma align(natural)122struct B {123int i2;124struct A a;125};126#pragma align(reset)127
128int d = sizeof(B);129
130// CHECK: *** Dumping AST Record Layout
131// CHECK-NEXT: 0 | struct test4::A
132// CHECK-NEXT: 0 | int i1
133// CHECK-NEXT: 4 | double d
134// CHECK-NEXT: | [sizeof=12, dsize=12, align=4, preferredalign=4,
135// CHECK-NEXT: | nvsize=12, nvalign=4, preferrednvalign=4]
136
137// CHECK: *** Dumping AST Record Layout
138// CHECK-NEXT: 0 | struct test4::B
139// CHECK-NEXT: 0 | int i2
140// CHECK-NEXT: 4 | struct test4::A a
141// CHECK-NEXT: 4 | int i1
142// CHECK-NEXT: 8 | double d
143// CHECK-NEXT: | [sizeof=16, dsize=16, align=4, preferredalign=4,
144// CHECK-NEXT: | nvsize=16, nvalign=4, preferrednvalign=4]
145
146} // namespace test4147