Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions tests/auxiliary/minicore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
decl_macro,
f16,
f128,
transparent_unions,
asm_experimental_arch,
unboxed_closures
)]
Expand Down Expand Up @@ -127,6 +128,25 @@ pub struct ManuallyDrop<T: PointeeSized> {
}
impl<T: Copy + PointeeSized> Copy for ManuallyDrop<T> {}

#[lang = "maybe_uninit"]
#[repr(transparent)]
pub union MaybeUninit<T> {
uninit: (),
value: ManuallyDrop<T>,
}

impl<T: Copy + PointeeSized> Copy for MaybeUninit<T> {}

impl<T> MaybeUninit<T> {
pub const fn uninit() -> Self {
Self { uninit: () }
}

pub const fn new(value: T) -> Self {
Self { value: ManuallyDrop { value } }
}
}

#[repr(transparent)]
#[rustc_nonnull_optimization_guaranteed]
pub struct NonNull<T: ?Sized> {
Expand Down
14 changes: 10 additions & 4 deletions tests/ui/cmse-nonsecure/cmse-nonsecure-call/return-via-stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,25 @@ struct Test {
i128: extern "cmse-nonsecure-call" fn() -> i128, //~ ERROR [E0798]
}

#[repr(C)]
pub union ReprCUnionU64 {
#[repr(Rust)]
pub union ReprRustUnionU64 {
_unused: u64,
}

#[repr(Rust)]
pub union ReprRustUnionU64 {
#[repr(C)]
pub union ReprCUnionU64 {
_unused: u64,
}

#[no_mangle]
pub fn test_union(
f1: extern "cmse-nonsecure-call" fn() -> ReprRustUnionU64, //~ ERROR [E0798]
f2: extern "cmse-nonsecure-call" fn() -> ReprCUnionU64, //~ ERROR [E0798]

// MaybeUninit is a transparent union, and hence MaybeUninit<u64> is abi-compatible with u64,
// and thus allowed as a return type.
Comment thread
WaffleLapkin marked this conversation as resolved.
f3: extern "cmse-nonsecure-call" fn() -> MaybeUninit<u32>,
f4: extern "cmse-nonsecure-call" fn() -> MaybeUninit<u64>,
f5: extern "cmse-nonsecure-call" fn() -> MaybeUninit<f64>,
) {
}
23 changes: 23 additions & 0 deletions tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-via-stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,26 @@ pub extern "cmse-nonsecure-entry" fn four(_: Four) {}

#[no_mangle]
pub extern "cmse-nonsecure-entry" fn five(_: Five) {} //~ ERROR [E0798]

#[repr(Rust)]
pub union ReprRustUnionU64 {
_unused: u64,
}

#[repr(C)]
pub union ReprCUnionU64 {
_unused: u64,
}

#[no_mangle]
#[allow(improper_ctypes_definitions)]
pub extern "cmse-nonsecure-entry" fn union_rust(_: ReprRustUnionU64) {}

#[no_mangle]
pub extern "cmse-nonsecure-entry" fn union_c(_: ReprCUnionU64) {}

#[no_mangle]
pub extern "cmse-nonsecure-entry" fn maybe_uninit_32bit(_: MaybeUninit<u32>) {}

#[no_mangle]
pub extern "cmse-nonsecure-entry" fn maybe_uninit_64bit(_: MaybeUninit<f64>) {}
Loading