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