]> git.lizzy.rs Git - rust.git/blob - tests/codegen/repr-transparent-aggregates-1.rs
Rollup merge of #107190 - fmease:fix-81698, r=compiler-errors
[rust.git] / tests / codegen / repr-transparent-aggregates-1.rs
1 // compile-flags: -O -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-s390x
12 // ignore-windows
13 // See repr-transparent.rs
14
15 #![feature(transparent_unions)]
16
17 #![crate_type="lib"]
18
19
20 #[derive(Clone, Copy)]
21 #[repr(C)]
22 pub struct BigS([u32; 16]);
23
24 #[repr(transparent)]
25 pub struct TsBigS(BigS);
26
27 #[repr(transparent)]
28 pub union TuBigS {
29     field: BigS,
30 }
31
32 #[repr(transparent)]
33 pub enum TeBigS {
34     Variant(BigS),
35 }
36
37 // CHECK: define{{.*}}void @test_BigS({{%BigS\*|ptr}} [[BIGS_RET_ATTRS1:.*]] sret(%BigS) [[BIGS_RET_ATTRS2:.*]], {{%BigS\*|ptr}} [[BIGS_ARG_ATTRS1:.*]] byval(%BigS) [[BIGS_ARG_ATTRS2:.*]])
38 #[no_mangle]
39 pub extern "C" fn test_BigS(_: BigS) -> BigS { loop {} }
40
41 // CHECK: define{{.*}}void @test_TsBigS({{%TsBigS\*|ptr}} [[BIGS_RET_ATTRS1]] sret(%TsBigS) [[BIGS_RET_ATTRS2]], {{%TsBigS\*|ptr}} [[BIGS_ARG_ATTRS1]] byval(%TsBigS) [[BIGS_ARG_ATTRS2:.*]])
42 #[no_mangle]
43 pub extern "C" fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} }
44
45 // CHECK: define{{.*}}void @test_TuBigS({{%TuBigS\*|ptr}} [[BIGS_RET_ATTRS1]] sret(%TuBigS) [[BIGS_RET_ATTRS2]], {{%TuBigS\*|ptr}} [[BIGS_ARG_ATTRS1]] byval(%TuBigS) [[BIGS_ARG_ATTRS2:.*]])
46 #[no_mangle]
47 pub extern "C" fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} }
48
49 // CHECK: define{{.*}}void @test_TeBigS({{%"TeBigS::Variant"\*|ptr}} [[BIGS_RET_ATTRS1]] sret(%"TeBigS::Variant") [[BIGS_RET_ATTRS2]], {{%"TeBigS::Variant"\*|ptr}} [[BIGS_ARG_ATTRS1]] byval(%"TeBigS::Variant") [[BIGS_ARG_ATTRS2]])
50 #[no_mangle]
51 pub extern "C" fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} }
52
53
54 #[derive(Clone, Copy)]
55 #[repr(C)]
56 pub union BigU {
57     foo: [u32; 16],
58 }
59
60 #[repr(transparent)]
61 pub struct TsBigU(BigU);
62
63 #[repr(transparent)]
64 pub union TuBigU {
65     field: BigU,
66 }
67
68 #[repr(transparent)]
69 pub enum TeBigU {
70     Variant(BigU),
71 }
72
73 // CHECK: define{{.*}}void @test_BigU({{%BigU\*|ptr}} [[BIGU_RET_ATTRS1:.*]] sret(%BigU) [[BIGU_RET_ATTRS2:.*]], {{%BigU\*|ptr}} [[BIGU_ARG_ATTRS1:.*]] byval(%BigU) [[BIGU_ARG_ATTRS2:.*]])
74 #[no_mangle]
75 pub extern "C" fn test_BigU(_: BigU) -> BigU { loop {} }
76
77 // CHECK: define{{.*}}void @test_TsBigU({{%TsBigU\*|ptr}} [[BIGU_RET_ATTRS1:.*]] sret(%TsBigU) [[BIGU_RET_ATTRS2:.*]], {{%TsBigU\*|ptr}} [[BIGU_ARG_ATTRS1]] byval(%TsBigU) [[BIGU_ARG_ATTRS2]])
78 #[no_mangle]
79 pub extern "C" fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} }
80
81 // CHECK: define{{.*}}void @test_TuBigU({{%TuBigU\*|ptr}} [[BIGU_RET_ATTRS1]] sret(%TuBigU) [[BIGU_RET_ATTRS2:.*]], {{%TuBigU\*|ptr}} [[BIGU_ARG_ATTRS1]] byval(%TuBigU) [[BIGU_ARG_ATTRS2]])
82 #[no_mangle]
83 pub extern "C" fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} }
84
85 // CHECK: define{{.*}}void @test_TeBigU({{%"TeBigU::Variant"\*|ptr}} [[BIGU_RET_ATTRS1]] sret(%"TeBigU::Variant") [[BIGU_RET_ATTRS2:.*]], {{%"TeBigU::Variant"\*|ptr}} [[BIGU_ARG_ATTRS1]] byval(%"TeBigU::Variant") [[BIGU_ARG_ATTRS2]])
86 #[no_mangle]
87 pub extern "C" fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} }