Skip to content

Commit 0163768

Browse files
committed
rustc_target/loongarch: Fix passing of transparent unions with only one non-ZST member
This ensures that `MaybeUninit<T>` has the same ABI as `T` when passed through an `extern "C"` function. Fixes #115509
1 parent bdb0fa3 commit 0163768

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

compiler/rustc_target/src/abi/call/loongarch.rs

+11
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,17 @@ where
8383
}
8484
FieldsShape::Union(_) => {
8585
if !arg_layout.is_zst() {
86+
if arg_layout.is_transparent() {
87+
let non_1zst_elem = arg_layout.non_1zst_field(cx).expect("not exactly one non-1-ZST field in non-ZST repr(transparent) union").1;
88+
return should_use_fp_conv_helper(
89+
cx,
90+
&non_1zst_elem,
91+
xlen,
92+
flen,
93+
field1_kind,
94+
field2_kind,
95+
);
96+
}
8697
return Err(CannotUseFpConv);
8798
}
8899
}

0 commit comments

Comments
 (0)