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