]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/repr-transparent-aggregates-2.rs
Implement RFC 2645 (transparent enums and unions)
[rust.git] / src / test / codegen / repr-transparent-aggregates-2.rs
1 // compile-flags: -C no-prepopulate-passes
2
3 // ignore-aarch64
4 // ignore-asmjs
5 // ignore-mips64
6 // ignore-powerpc
7 // ignore-powerpc64
8 // ignore-powerpc64le
9 // ignore-s390x
10 // ignore-sparc
11 // ignore-sparc64
12 // ignore-wasm
13 // ignore-x86
14 // ignore-x86_64
15 // See repr-transparent.rs
16
17 #![feature(transparent_enums, transparent_unions)]
18
19 #![crate_type="lib"]
20
21
22 #[derive(Clone, Copy)]
23 #[repr(C)]
24 pub struct BigS([u32; 16]);
25
26 #[repr(transparent)]
27 pub struct TsBigS(BigS);
28
29 #[repr(transparent)]
30 pub union TuBigS {
31     field: BigS,
32 }
33
34 #[repr(transparent)]
35 pub enum TeBigS {
36     Variant(BigS),
37 }
38
39 // CHECK: define void @test_BigS(%BigS* [[BIGS_RET_ATTRS:.*]], [16 x i32]
40 #[no_mangle]
41 pub extern fn test_BigS(_: BigS) -> BigS { loop {} }
42
43 // CHECK: define void @test_TsBigS(%TsBigS* [[BIGS_RET_ATTRS]], [16 x i32]
44 #[no_mangle]
45 pub extern fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} }
46
47 // CHECK: define void @test_TuBigS(%TuBigS* [[BIGS_RET_ATTRS]], [16 x i32]
48 #[no_mangle]
49 pub extern fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} }
50
51 // CHECK: define void @test_TeBigS(%"TeBigS::Variant"* [[BIGS_RET_ATTRS]], [16 x i32]
52 #[no_mangle]
53 pub extern fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} }
54
55
56 #[derive(Clone, Copy)]
57 #[repr(C)]
58 pub union BigU {
59     foo: [u32; 16],
60 }
61
62 #[repr(transparent)]
63 pub struct TsBigU(BigU);
64
65 #[repr(transparent)]
66 pub union TuBigU {
67     field: BigU,
68 }
69
70 #[repr(transparent)]
71 pub enum TeBigU {
72     Variant(BigU),
73 }
74
75 // CHECK: define void @test_BigU(%BigU* [[BIGU_RET_ATTRS:.*]], [16 x i32]
76 #[no_mangle]
77 pub extern fn test_BigU(_: BigU) -> BigU { loop {} }
78
79 // CHECK: define void @test_TsBigU(%TsBigU* [[BIGU_RET_ATTRS:.*]], [16 x i32]
80 #[no_mangle]
81 pub extern fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} }
82
83 // CHECK: define void @test_TuBigU(%TuBigU* [[BIGU_RET_ATTRS]], [16 x i32]
84 #[no_mangle]
85 pub extern fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} }
86
87 // CHECK: define void @test_TeBigU(%"TeBigU::Variant"* [[BIGU_RET_ATTRS]], [16 x i32]
88 #[no_mangle]
89 pub extern fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} }