Skip to content

Commit

Permalink
rustc_target/loongarch: Fix passing of transparent unions with only o…
Browse files Browse the repository at this point in the history
…ne non-ZST member

This ensures that `MaybeUninit<T>` has the same ABI as `T` when passed
through an `extern "C"` function.

Fixes #115509
  • Loading branch information
heiher committed Sep 20, 2023
1 parent bdb0fa3 commit 0163768
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions compiler/rustc_target/src/abi/call/loongarch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ where
}
FieldsShape::Union(_) => {
if !arg_layout.is_zst() {
if arg_layout.is_transparent() {
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;
return should_use_fp_conv_helper(
cx,
&non_1zst_elem,
xlen,
flen,
field1_kind,
field2_kind,
);
}
return Err(CannotUseFpConv);
}
}
Expand Down

0 comments on commit 0163768

Please sign in to comment.