Skip to content

Commit 950ad7e

Browse files
tests: Test for newly corrected alignments on AIX
1 parent 42a6dd2 commit 950ad7e

2 files changed

Lines changed: 212 additions & 126 deletions

File tree

Lines changed: 86 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,192 +1,226 @@
1-
//@ check-pass
21
//@ compile-flags: --target powerpc64-ibm-aix
32
//@ needs-llvm-components: powerpc
43
//@ add-minicore
54
//@ ignore-backends: gcc
6-
#![feature(no_core)]
5+
#![feature(no_core, rustc_attrs)]
76
#![no_core]
87
#![no_std]
98
#![crate_type = "lib"]
109

1110
extern crate minicore;
1211
use minicore::*;
1312

14-
#[warn(uses_power_alignment)]
13+
#[rustc_layout(align)]
1514
#[repr(C)]
16-
pub struct Floats {
15+
pub struct Floats { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) }
1716
a: f64,
1817
b: u8,
19-
c: f64, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
18+
c: f64,
2019
d: f32,
2120
}
2221

23-
pub struct Floats2 {
22+
#[rustc_layout(align)]
23+
pub struct Floats2 { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) }
2424
a: f64,
2525
b: u32,
2626
c: f64,
2727
}
2828

29+
#[rustc_layout(align)]
2930
#[repr(C)]
30-
pub struct Floats3 {
31+
pub struct Floats3 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) }
3132
a: f32,
3233
b: f32,
3334
c: i64,
3435
}
3536

37+
#[rustc_layout(align)]
3638
#[repr(C)]
37-
pub struct Floats4 {
39+
pub struct Floats4 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) }
3840
a: u64,
3941
b: u32,
4042
c: f32,
4143
}
4244

45+
#[rustc_layout(align)]
4346
#[repr(C)]
44-
pub struct Floats5 {
47+
pub struct Floats5 { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) }
4548
a: f32,
46-
b: f64, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
49+
b: f64,
4750
c: f32,
4851
}
4952

53+
#[rustc_layout(align)]
5054
#[repr(C)]
51-
pub struct FloatAgg1 {
55+
pub struct FloatAgg1 { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) }
5256
x: Floats,
53-
y: f64, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
57+
y: f64,
5458
}
5559

60+
#[rustc_layout(align)]
5661
#[repr(C)]
57-
pub struct FloatAgg2 {
62+
pub struct FloatAgg2 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) }
5863
x: i64,
59-
y: Floats, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
64+
y: Floats,
6065
}
6166

67+
#[rustc_layout(align)]
6268
#[repr(C)]
63-
pub struct FloatAgg3 {
69+
pub struct FloatAgg3 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) }
6470
x: FloatAgg1,
65-
// NOTE: the "power" alignment rule is infectious to nested struct fields.
66-
y: FloatAgg2, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
67-
z: FloatAgg2, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
71+
y: FloatAgg2,
72+
z: FloatAgg2,
6873
}
6974

75+
#[rustc_layout(align)]
7076
#[repr(C)]
71-
pub struct FloatAgg4 {
77+
pub struct FloatAgg4 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) }
7278
x: FloatAgg1,
73-
y: FloatAgg2, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
79+
y: FloatAgg2,
7480
}
7581

82+
#[rustc_layout(align)]
7683
#[repr(C)]
77-
pub struct FloatAgg5 {
84+
pub struct FloatAgg5 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) }
7885
x: FloatAgg1,
79-
y: FloatAgg2, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
80-
z: FloatAgg3, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
86+
y: FloatAgg2,
87+
z: FloatAgg3,
8188
}
8289

90+
#[rustc_layout(align)]
8391
#[repr(C)]
84-
pub struct FloatAgg6 {
92+
pub struct FloatAgg6 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) }
8593
x: i64,
86-
y: Floats, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
94+
y: Floats,
8795
z: u8,
8896
}
8997

98+
#[rustc_layout(align)]
9099
#[repr(C)]
91-
pub struct FloatAgg7 {
100+
pub struct FloatAgg7 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) }
92101
x: i64,
93-
y: Floats, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
102+
y: Floats,
94103
z: u8,
95104
zz: f32,
96105
}
97106

107+
#[rustc_layout(align)]
98108
#[repr(C)]
99-
pub struct A {
109+
pub struct A { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) }
100110
d: f64,
101111
}
112+
113+
#[rustc_layout(align)]
102114
#[repr(C)]
103-
pub struct B {
115+
pub struct B { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) }
104116
a: A,
105117
f: f32,
106-
d: f64, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
118+
d: f64,
107119
}
120+
121+
#[rustc_layout(align)]
108122
#[repr(C)]
109-
pub struct C {
123+
pub struct C { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) }
110124
c: u8,
111-
b: B, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
125+
b: B,
112126
}
127+
128+
#[rustc_layout(align)]
113129
#[repr(C)]
114-
pub struct D {
130+
pub struct D { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) }
115131
x: f64,
116132
}
133+
134+
#[rustc_layout(align)]
117135
#[repr(C)]
118-
pub struct E {
136+
pub struct E { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) }
119137
x: i32,
120-
d: D, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
138+
d: D,
121139
}
140+
141+
#[rustc_layout(align)]
122142
#[repr(C)]
123-
pub struct F {
143+
pub struct F { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) }
124144
a: u8,
125-
b: f64, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
145+
b: f64,
126146
}
147+
148+
#[rustc_layout(align)]
127149
#[repr(C)]
128-
pub struct G {
150+
pub struct G { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) }
129151
a: u8,
130152
b: u8,
131-
c: f64, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
153+
c: f64,
132154
d: f32,
133-
e: f64, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
155+
e: f64,
134156
}
135-
// Should not warn on #[repr(packed)].
157+
158+
#[rustc_layout(align)]
136159
#[repr(packed)]
137-
pub struct H {
160+
pub struct H { //~ ERROR: align: AbiAlign { abi: Align(1 bytes) }
138161
a: u8,
139162
b: u8,
140163
c: f64,
141164
d: f32,
142165
e: f64,
143166
}
167+
168+
#[rustc_layout(align)]
144169
#[repr(C, packed)]
145-
pub struct I {
170+
pub struct I { //~ ERROR: align: AbiAlign { abi: Align(1 bytes) }
146171
a: u8,
147172
b: u8,
148173
c: f64,
149174
d: f32,
150175
e: f64,
151176
}
177+
178+
179+
#[rustc_layout(align)]
152180
#[repr(C)]
153-
pub struct J {
181+
pub struct J { //~ ERROR: align: AbiAlign { abi: Align(1 bytes) }
154182
a: u8,
155183
b: I,
156184
}
157-
// The lint also ignores diagnosing #[repr(align(n))].
185+
186+
#[rustc_layout(align)]
158187
#[repr(C, align(8))]
159-
pub struct K {
188+
pub struct K { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) }
160189
a: u8,
161190
b: u8,
162191
c: f64,
163192
d: f32,
164193
e: f64,
165194
}
195+
196+
#[rustc_layout(align)]
166197
#[repr(C)]
167-
pub struct L {
198+
pub struct L { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) }
168199
a: u8,
169200
b: K,
170201
}
202+
203+
#[rustc_layout(align)]
171204
#[repr(C, align(8))]
172-
pub struct M {
205+
pub struct M { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) }
173206
a: u8,
174207
b: K,
175208
c: L,
176209
}
177210

178-
// The lint ignores unions
211+
#[rustc_layout(align)]
179212
#[repr(C)]
180-
pub union Union {
213+
pub union Union { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) }
181214
a: f64,
182215
b: u8,
183216
c: f64,
184217
d: f32,
185218
}
186219

187-
// The lint ignores enums
220+
221+
#[rustc_layout(align)]
188222
#[repr(C)]
189-
pub enum Enum {
223+
pub enum Enum { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) }
190224
A { a: f64, b: u8, c: f64, d: f32 },
191225
B,
192226
}

0 commit comments

Comments
 (0)