|
1 | | -//@ check-pass |
2 | 1 | //@ compile-flags: --target powerpc64-ibm-aix |
3 | 2 | //@ needs-llvm-components: powerpc |
4 | 3 | //@ add-minicore |
5 | 4 | //@ ignore-backends: gcc |
6 | | -#![feature(no_core)] |
| 5 | +#![feature(no_core, rustc_attrs)] |
7 | 6 | #![no_core] |
8 | 7 | #![no_std] |
9 | 8 | #![crate_type = "lib"] |
10 | 9 |
|
11 | 10 | extern crate minicore; |
12 | 11 | use minicore::*; |
13 | 12 |
|
14 | | -#[warn(uses_power_alignment)] |
| 13 | +#[rustc_layout(align)] |
15 | 14 | #[repr(C)] |
16 | | -pub struct Floats { |
| 15 | +pub struct Floats { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) } |
17 | 16 | a: f64, |
18 | 17 | 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, |
20 | 19 | d: f32, |
21 | 20 | } |
22 | 21 |
|
23 | | -pub struct Floats2 { |
| 22 | +#[rustc_layout(align)] |
| 23 | +pub struct Floats2 { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) } |
24 | 24 | a: f64, |
25 | 25 | b: u32, |
26 | 26 | c: f64, |
27 | 27 | } |
28 | 28 |
|
| 29 | +#[rustc_layout(align)] |
29 | 30 | #[repr(C)] |
30 | | -pub struct Floats3 { |
| 31 | +pub struct Floats3 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) } |
31 | 32 | a: f32, |
32 | 33 | b: f32, |
33 | 34 | c: i64, |
34 | 35 | } |
35 | 36 |
|
| 37 | +#[rustc_layout(align)] |
36 | 38 | #[repr(C)] |
37 | | -pub struct Floats4 { |
| 39 | +pub struct Floats4 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) } |
38 | 40 | a: u64, |
39 | 41 | b: u32, |
40 | 42 | c: f32, |
41 | 43 | } |
42 | 44 |
|
| 45 | +#[rustc_layout(align)] |
43 | 46 | #[repr(C)] |
44 | | -pub struct Floats5 { |
| 47 | +pub struct Floats5 { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) } |
45 | 48 | 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, |
47 | 50 | c: f32, |
48 | 51 | } |
49 | 52 |
|
| 53 | +#[rustc_layout(align)] |
50 | 54 | #[repr(C)] |
51 | | -pub struct FloatAgg1 { |
| 55 | +pub struct FloatAgg1 { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) } |
52 | 56 | 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, |
54 | 58 | } |
55 | 59 |
|
| 60 | +#[rustc_layout(align)] |
56 | 61 | #[repr(C)] |
57 | | -pub struct FloatAgg2 { |
| 62 | +pub struct FloatAgg2 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) } |
58 | 63 | 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, |
60 | 65 | } |
61 | 66 |
|
| 67 | +#[rustc_layout(align)] |
62 | 68 | #[repr(C)] |
63 | | -pub struct FloatAgg3 { |
| 69 | +pub struct FloatAgg3 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) } |
64 | 70 | 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, |
68 | 73 | } |
69 | 74 |
|
| 75 | +#[rustc_layout(align)] |
70 | 76 | #[repr(C)] |
71 | | -pub struct FloatAgg4 { |
| 77 | +pub struct FloatAgg4 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) } |
72 | 78 | 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, |
74 | 80 | } |
75 | 81 |
|
| 82 | +#[rustc_layout(align)] |
76 | 83 | #[repr(C)] |
77 | | -pub struct FloatAgg5 { |
| 84 | +pub struct FloatAgg5 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) } |
78 | 85 | 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, |
81 | 88 | } |
82 | 89 |
|
| 90 | +#[rustc_layout(align)] |
83 | 91 | #[repr(C)] |
84 | | -pub struct FloatAgg6 { |
| 92 | +pub struct FloatAgg6 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) } |
85 | 93 | 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, |
87 | 95 | z: u8, |
88 | 96 | } |
89 | 97 |
|
| 98 | +#[rustc_layout(align)] |
90 | 99 | #[repr(C)] |
91 | | -pub struct FloatAgg7 { |
| 100 | +pub struct FloatAgg7 { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) } |
92 | 101 | 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, |
94 | 103 | z: u8, |
95 | 104 | zz: f32, |
96 | 105 | } |
97 | 106 |
|
| 107 | +#[rustc_layout(align)] |
98 | 108 | #[repr(C)] |
99 | | -pub struct A { |
| 109 | +pub struct A { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) } |
100 | 110 | d: f64, |
101 | 111 | } |
| 112 | + |
| 113 | +#[rustc_layout(align)] |
102 | 114 | #[repr(C)] |
103 | | -pub struct B { |
| 115 | +pub struct B { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) } |
104 | 116 | a: A, |
105 | 117 | 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, |
107 | 119 | } |
| 120 | + |
| 121 | +#[rustc_layout(align)] |
108 | 122 | #[repr(C)] |
109 | | -pub struct C { |
| 123 | +pub struct C { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) } |
110 | 124 | 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, |
112 | 126 | } |
| 127 | + |
| 128 | +#[rustc_layout(align)] |
113 | 129 | #[repr(C)] |
114 | | -pub struct D { |
| 130 | +pub struct D { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) } |
115 | 131 | x: f64, |
116 | 132 | } |
| 133 | + |
| 134 | +#[rustc_layout(align)] |
117 | 135 | #[repr(C)] |
118 | | -pub struct E { |
| 136 | +pub struct E { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) } |
119 | 137 | 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, |
121 | 139 | } |
| 140 | + |
| 141 | +#[rustc_layout(align)] |
122 | 142 | #[repr(C)] |
123 | | -pub struct F { |
| 143 | +pub struct F { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) } |
124 | 144 | 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, |
126 | 146 | } |
| 147 | + |
| 148 | +#[rustc_layout(align)] |
127 | 149 | #[repr(C)] |
128 | | -pub struct G { |
| 150 | +pub struct G { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) } |
129 | 151 | a: u8, |
130 | 152 | 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, |
132 | 154 | 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, |
134 | 156 | } |
135 | | -// Should not warn on #[repr(packed)]. |
| 157 | + |
| 158 | +#[rustc_layout(align)] |
136 | 159 | #[repr(packed)] |
137 | | -pub struct H { |
| 160 | +pub struct H { //~ ERROR: align: AbiAlign { abi: Align(1 bytes) } |
138 | 161 | a: u8, |
139 | 162 | b: u8, |
140 | 163 | c: f64, |
141 | 164 | d: f32, |
142 | 165 | e: f64, |
143 | 166 | } |
| 167 | + |
| 168 | +#[rustc_layout(align)] |
144 | 169 | #[repr(C, packed)] |
145 | | -pub struct I { |
| 170 | +pub struct I { //~ ERROR: align: AbiAlign { abi: Align(1 bytes) } |
146 | 171 | a: u8, |
147 | 172 | b: u8, |
148 | 173 | c: f64, |
149 | 174 | d: f32, |
150 | 175 | e: f64, |
151 | 176 | } |
| 177 | + |
| 178 | + |
| 179 | +#[rustc_layout(align)] |
152 | 180 | #[repr(C)] |
153 | | -pub struct J { |
| 181 | +pub struct J { //~ ERROR: align: AbiAlign { abi: Align(1 bytes) } |
154 | 182 | a: u8, |
155 | 183 | b: I, |
156 | 184 | } |
157 | | -// The lint also ignores diagnosing #[repr(align(n))]. |
| 185 | + |
| 186 | +#[rustc_layout(align)] |
158 | 187 | #[repr(C, align(8))] |
159 | | -pub struct K { |
| 188 | +pub struct K { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) } |
160 | 189 | a: u8, |
161 | 190 | b: u8, |
162 | 191 | c: f64, |
163 | 192 | d: f32, |
164 | 193 | e: f64, |
165 | 194 | } |
| 195 | + |
| 196 | +#[rustc_layout(align)] |
166 | 197 | #[repr(C)] |
167 | | -pub struct L { |
| 198 | +pub struct L { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) } |
168 | 199 | a: u8, |
169 | 200 | b: K, |
170 | 201 | } |
| 202 | + |
| 203 | +#[rustc_layout(align)] |
171 | 204 | #[repr(C, align(8))] |
172 | | -pub struct M { |
| 205 | +pub struct M { //~ ERROR: align: AbiAlign { abi: Align(8 bytes) } |
173 | 206 | a: u8, |
174 | 207 | b: K, |
175 | 208 | c: L, |
176 | 209 | } |
177 | 210 |
|
178 | | -// The lint ignores unions |
| 211 | +#[rustc_layout(align)] |
179 | 212 | #[repr(C)] |
180 | | -pub union Union { |
| 213 | +pub union Union { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) } |
181 | 214 | a: f64, |
182 | 215 | b: u8, |
183 | 216 | c: f64, |
184 | 217 | d: f32, |
185 | 218 | } |
186 | 219 |
|
187 | | -// The lint ignores enums |
| 220 | + |
| 221 | +#[rustc_layout(align)] |
188 | 222 | #[repr(C)] |
189 | | -pub enum Enum { |
| 223 | +pub enum Enum { //~ ERROR: align: AbiAlign { abi: Align(4 bytes) } |
190 | 224 | A { a: f64, b: u8, c: f64, d: f32 }, |
191 | 225 | B, |
192 | 226 | } |
0 commit comments