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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
//@ check-pass
//@ compile-flags: --target powerpc64-ibm-aix
//@ needs-llvm-components: powerpc
//@ add-core-stubs
#![feature(no_core)]
#![no_core]
#![no_std]
extern crate minicore;
use minicore::*;
#[warn(uses_power_alignment)]
#[repr(C)]
pub struct Floats {
a: f64,
b: u8,
c: f64, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
d: f32,
}
pub struct Floats2 {
a: f64,
b: u32,
c: f64,
}
#[repr(C)]
pub struct Floats3 {
a: f32,
b: f32,
c: i64,
}
#[repr(C)]
pub struct Floats4 {
a: u64,
b: u32,
c: f32,
}
#[repr(C)]
pub struct Floats5 {
a: f32,
b: f64, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
c: f32,
}
#[repr(C)]
pub struct FloatAgg1 {
x: Floats,
y: f64, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
}
#[repr(C)]
pub struct FloatAgg2 {
x: i64,
y: Floats, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
}
#[repr(C)]
pub struct FloatAgg3 {
x: FloatAgg1,
// NOTE: the "power" alignment rule is infectious to nested struct fields.
y: FloatAgg2, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
z: FloatAgg2, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
}
#[repr(C)]
pub struct FloatAgg4 {
x: FloatAgg1,
y: FloatAgg2, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
}
#[repr(C)]
pub struct FloatAgg5 {
x: FloatAgg1,
y: FloatAgg2, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
z: FloatAgg3, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
}
#[repr(C)]
pub struct FloatAgg6 {
x: i64,
y: Floats, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
z: u8,
}
#[repr(C)]
pub struct FloatAgg7 {
x: i64,
y: Floats, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
z: u8,
zz: f32,
}
#[repr(C)]
pub struct A {
d: f64,
}
#[repr(C)]
pub struct B {
a: A,
f: f32,
d: f64, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
}
#[repr(C)]
pub struct C {
c: u8,
b: B, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
}
#[repr(C)]
pub struct D {
x: f64,
}
#[repr(C)]
pub struct E {
x: i32,
d: D, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
}
#[repr(C)]
pub struct F {
a: u8,
b: f64, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
}
#[repr(C)]
pub struct G {
a: u8,
b: u8,
c: f64, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
d: f32,
e: f64, //~ WARNING repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type
}
// Should not warn on #[repr(packed)].
#[repr(packed)]
pub struct H {
a: u8,
b: u8,
c: f64,
d: f32,
e: f64,
}
#[repr(C, packed)]
pub struct I {
a: u8,
b: u8,
c: f64,
d: f32,
e: f64,
}
#[repr(C)]
pub struct J {
a: u8,
b: I,
}
// The lint also ignores diagnosing #[repr(align(n))].
#[repr(C, align(8))]
pub struct K {
a: u8,
b: u8,
c: f64,
d: f32,
e: f64,
}
#[repr(C)]
pub struct L {
a: u8,
b: K,
}
#[repr(C, align(8))]
pub struct M {
a: u8,
b: K,
c: L,
}
fn main() { }
|