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