Skip to content

Commit 6abc782

Browse files
tests: Test for newly corrected alignments on AIX
1 parent 775906a commit 6abc782

File tree

2 files changed

+196
-123
lines changed

2 files changed

+196
-123
lines changed
Lines changed: 82 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,176 +1,209 @@
1-
//@ check-pass
21
//@ compile-flags: --target powerpc64-ibm-aix
32
//@ needs-llvm-components: powerpc
43
//@ add-core-stubs
5-
#![feature(no_core)]
4+
#![feature(no_core, rustc_attrs)]
65
#![no_core]
76
#![no_std]
87

98
extern crate minicore;
109
use minicore::*;
1110

12-
#[warn(uses_power_alignment)]
13-
11+
#[rustc_layout(align)]
1412
#[repr(C)]
15-
pub struct Floats {
13+
pub struct Floats { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) }
1614
a: f64,
1715
b: u8,
18-
c: f64, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
16+
c: f64,
1917
d: f32,
2018
}
2119

22-
pub struct Floats2 {
20+
#[rustc_layout(align)]
21+
pub struct Floats2 { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) }
2322
a: f64,
2423
b: u32,
2524
c: f64,
2625
}
2726

27+
#[rustc_layout(align)]
2828
#[repr(C)]
29-
pub struct Floats3 {
29+
pub struct Floats3 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) }
3030
a: f32,
3131
b: f32,
3232
c: i64,
3333
}
3434

35+
#[rustc_layout(align)]
3536
#[repr(C)]
36-
pub struct Floats4 {
37+
pub struct Floats4 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) }
3738
a: u64,
3839
b: u32,
3940
c: f32,
4041
}
4142

43+
#[rustc_layout(align)]
4244
#[repr(C)]
43-
pub struct Floats5 {
45+
pub struct Floats5 { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) }
4446
a: f32,
45-
b: f64, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
47+
b: f64,
4648
c: f32,
4749
}
4850

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

58+
#[rustc_layout(align)]
5559
#[repr(C)]
56-
pub struct FloatAgg2 {
60+
pub struct FloatAgg2 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) }
5761
x: i64,
58-
y: Floats, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
62+
y: Floats,
5963
}
6064

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

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

80+
#[rustc_layout(align)]
7581
#[repr(C)]
76-
pub struct FloatAgg5 {
82+
pub struct FloatAgg5 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) }
7783
x: FloatAgg1,
78-
y: FloatAgg2, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
79-
z: FloatAgg3, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
84+
y: FloatAgg2,
85+
z: FloatAgg3,
8086
}
8187

88+
#[rustc_layout(align)]
8289
#[repr(C)]
83-
pub struct FloatAgg6 {
90+
pub struct FloatAgg6 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) }
8491
x: i64,
85-
y: Floats, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
92+
y: Floats,
8693
z: u8,
8794
}
8895

96+
#[rustc_layout(align)]
8997
#[repr(C)]
90-
pub struct FloatAgg7 {
98+
pub struct FloatAgg7 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) }
9199
x: i64,
92-
y: Floats, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
100+
y: Floats,
93101
z: u8,
94102
zz: f32,
95103
}
96104

105+
#[rustc_layout(align)]
97106
#[repr(C)]
98-
pub struct A {
107+
pub struct A { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) }
99108
d: f64,
100109
}
110+
111+
#[rustc_layout(align)]
101112
#[repr(C)]
102-
pub struct B {
113+
pub struct B { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) }
103114
a: A,
104115
f: f32,
105-
d: f64, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
116+
d: f64,
106117
}
118+
119+
#[rustc_layout(align)]
107120
#[repr(C)]
108-
pub struct C {
121+
pub struct C { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) }
109122
c: u8,
110-
b: B, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
123+
b: B,
111124
}
125+
126+
#[rustc_layout(align)]
112127
#[repr(C)]
113-
pub struct D {
128+
pub struct D { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) }
114129
x: f64,
115130
}
131+
132+
#[rustc_layout(align)]
116133
#[repr(C)]
117-
pub struct E {
134+
pub struct E { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) }
118135
x: i32,
119-
d: D, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
136+
d: D,
120137
}
138+
139+
#[rustc_layout(align)]
121140
#[repr(C)]
122-
pub struct F {
141+
pub struct F { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) }
123142
a: u8,
124-
b: f64, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
143+
b: f64,
125144
}
145+
146+
#[rustc_layout(align)]
126147
#[repr(C)]
127-
pub struct G {
148+
pub struct G { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) }
128149
a: u8,
129150
b: u8,
130-
c: f64, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
151+
c: f64,
131152
d: f32,
132-
e: f64, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
153+
e: f64,
133154
}
134-
// Should not warn on #[repr(packed)].
155+
156+
#[rustc_layout(align)]
135157
#[repr(packed)]
136-
pub struct H {
158+
pub struct H { //~ ERROR: align: AbiAlign { abi: Align(1 bytes) }
137159
a: u8,
138160
b: u8,
139161
c: f64,
140162
d: f32,
141163
e: f64,
142164
}
165+
166+
#[rustc_layout(align)]
143167
#[repr(C, packed)]
144-
pub struct I {
168+
pub struct I { //~ ERROR: align: AbiAlign { abi: Align(1 bytes) }
145169
a: u8,
146170
b: u8,
147171
c: f64,
148172
d: f32,
149173
e: f64,
150174
}
175+
176+
177+
#[rustc_layout(align)]
151178
#[repr(C)]
152-
pub struct J {
179+
pub struct J { //~ ERROR: align: AbiAlign { abi: Align(1 bytes) }
153180
a: u8,
154181
b: I,
155182
}
156-
// The lint also ignores diagnosing #[repr(align(n))].
183+
184+
#[rustc_layout(align)]
157185
#[repr(C, align(8))]
158-
pub struct K {
186+
pub struct K { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) }
159187
a: u8,
160188
b: u8,
161189
c: f64,
162190
d: f32,
163191
e: f64,
164192
}
193+
194+
#[rustc_layout(align)]
165195
#[repr(C)]
166-
pub struct L {
196+
pub struct L { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) }
167197
a: u8,
168198
b: K,
169199
}
200+
201+
#[rustc_layout(align)]
170202
#[repr(C, align(8))]
171-
pub struct M {
203+
pub struct M { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) }
172204
a: u8,
173205
b: K,
174206
c: L,
175207
}
208+
176209
fn main() { }

0 commit comments

Comments
 (0)