]> git.lizzy.rs Git - rust.git/blob - src/test/ui/layout/homogeneous-aggr-zero-sized-c-struct.rs
Rollup merge of #92959 - asquared31415:test-non-fn-help, r=estebank
[rust.git] / src / test / ui / layout / homogeneous-aggr-zero-sized-c-struct.rs
1 #![feature(rustc_attrs)]
2
3 // Show that `homogeneous_aggregate` code ignores zero-length C
4 // arrays.  This matches the recent C standard, though not the
5 // behavior of all older compilers, which sometimes consider `T[0]` to
6 // be a "flexible array member" (see discussion on #56877 for
7 // details).
8
9 #[repr(C)]
10 pub struct Foo {
11     x: u32
12 }
13
14 #[repr(C)]
15 pub struct Middle {
16     pub a: f32,
17     pub foo: [Foo; 0],
18     pub b: f32,
19 }
20
21 #[rustc_layout(homogeneous_aggregate)]
22 pub type TestMiddle = Middle;
23 //~^ ERROR homogeneous_aggregate: Ok(Homogeneous
24
25 #[repr(C)]
26 pub struct Final {
27     pub a: f32,
28     pub b: f32,
29     pub foo: [Foo; 0],
30 }
31
32 #[rustc_layout(homogeneous_aggregate)]
33 pub type TestFinal = Final;
34 //~^ ERROR homogeneous_aggregate: Ok(Homogeneous
35
36 fn main() { }