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