File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,19 +42,25 @@ struct Test {
4242 i128 : extern "cmse-nonsecure-call" fn ( ) -> i128 , //~ ERROR [E0798]
4343}
4444
45- #[ repr( C ) ]
46- pub union ReprCUnionU64 {
45+ #[ repr( Rust ) ]
46+ pub union ReprRustUnionU64 {
4747 _unused : u64 ,
4848}
4949
50- #[ repr( Rust ) ]
51- pub union ReprRustUnionU64 {
50+ #[ repr( C ) ]
51+ pub union ReprCUnionU64 {
5252 _unused : u64 ,
5353}
5454
5555#[ no_mangle]
5656pub fn test_union (
5757 f1 : extern "cmse-nonsecure-call" fn ( ) -> ReprRustUnionU64 , //~ ERROR [E0798]
5858 f2 : extern "cmse-nonsecure-call" fn ( ) -> ReprCUnionU64 , //~ ERROR [E0798]
59+
60+ // MaybeUninit is a transparent union, and hence MaybeUninit<u64> is abi-compatible with u64,
61+ // and thus allowed as a return type.
62+ f3 : extern "cmse-nonsecure-call" fn ( ) -> MaybeUninit < u32 > ,
63+ f4 : extern "cmse-nonsecure-call" fn ( ) -> MaybeUninit < u64 > ,
64+ f5 : extern "cmse-nonsecure-call" fn ( ) -> MaybeUninit < f64 > ,
5965) {
6066}
Original file line number Diff line number Diff line change @@ -45,3 +45,26 @@ pub extern "cmse-nonsecure-entry" fn four(_: Four) {}
4545
4646#[ no_mangle]
4747pub extern "cmse-nonsecure-entry" fn five ( _: Five ) { } //~ ERROR [E0798]
48+
49+ #[ repr( Rust ) ]
50+ pub union ReprRustUnionU64 {
51+ _unused : u64 ,
52+ }
53+
54+ #[ repr( C ) ]
55+ pub union ReprCUnionU64 {
56+ _unused : u64 ,
57+ }
58+
59+ #[ no_mangle]
60+ #[ allow( improper_ctypes_definitions) ]
61+ pub extern "cmse-nonsecure-entry" fn union_rust ( _: ReprRustUnionU64 ) { }
62+
63+ #[ no_mangle]
64+ pub extern "cmse-nonsecure-entry" fn union_c ( _: ReprCUnionU64 ) { }
65+
66+ #[ no_mangle]
67+ pub extern "cmse-nonsecure-entry" fn maybe_uninit_32bit ( _: MaybeUninit < u32 > ) { }
68+
69+ #[ no_mangle]
70+ pub extern "cmse-nonsecure-entry" fn maybe_uninit_64bit ( _: MaybeUninit < f64 > ) { }
You can’t perform that action at this time.
0 commit comments