-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve error messages for
C-cmse-nonsecure-entry
functions
- Loading branch information
1 parent
702987f
commit e71d2c3
Showing
14 changed files
with
601 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
//@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib | ||
//@ needs-llvm-components: arm | ||
#![feature(cmse_nonsecure_entry, c_variadic, no_core, lang_items)] | ||
#![no_core] | ||
#[lang = "sized"] | ||
pub trait Sized {} | ||
#[lang = "copy"] | ||
pub trait Copy {} | ||
impl Copy for u32 {} | ||
|
||
#[repr(C)] | ||
struct Wrapper<T>(T); | ||
|
||
impl<T: Copy> Wrapper<T> { | ||
extern "C-cmse-nonsecure-entry" fn ambient_generic(_: T, _: u32, _: u32, _: u32) -> u64 { | ||
//~^ ERROR [E0798] | ||
0 | ||
} | ||
|
||
extern "C-cmse-nonsecure-entry" fn ambient_generic_nested( | ||
//~^ ERROR [E0798] | ||
_: Wrapper<T>, | ||
_: u32, | ||
_: u32, | ||
_: u32, | ||
) -> u64 { | ||
0 | ||
} | ||
} | ||
|
||
extern "C-cmse-nonsecure-entry" fn introduced_generic<U: Copy>( | ||
//~^ ERROR [E0798] | ||
_: U, | ||
_: u32, | ||
_: u32, | ||
_: u32, | ||
) -> u64 { | ||
0 | ||
} | ||
|
||
extern "C-cmse-nonsecure-entry" fn impl_trait(_: impl Copy, _: u32, _: u32, _: u32) -> u64 { | ||
//~^ ERROR [E0798] | ||
0 | ||
} | ||
|
||
extern "C-cmse-nonsecure-entry" fn reference(x: &usize) -> usize { | ||
*x | ||
} | ||
|
||
trait Trait {} | ||
|
||
extern "C-cmse-nonsecure-entry" fn trait_object(x: &dyn Trait) -> &dyn Trait { | ||
//~^ ERROR return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers [E0798] | ||
x | ||
} | ||
|
||
extern "C-cmse-nonsecure-entry" fn static_trait_object( | ||
x: &'static dyn Trait, | ||
) -> &'static dyn Trait { | ||
//~^ ERROR return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers [E0798] | ||
x | ||
} | ||
|
||
#[repr(transparent)] | ||
struct WrapperTransparent<'a>(&'a dyn Trait); | ||
|
||
extern "C-cmse-nonsecure-entry" fn wrapped_trait_object( | ||
x: WrapperTransparent, | ||
) -> WrapperTransparent { | ||
//~^ ERROR return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers [E0798] | ||
x | ||
} | ||
|
||
extern "C-cmse-nonsecure-entry" fn c_variadic(_: u32, _: ...) { | ||
//~^ ERROR only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg | ||
//~| ERROR requires `va_list` lang_item | ||
} |
78 changes: 78 additions & 0 deletions
78
tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg | ||
--> $DIR/generics.rs:74:55 | ||
| | ||
LL | extern "C-cmse-nonsecure-entry" fn c_variadic(_: u32, _: ...) { | ||
| ^^^^^^ | ||
|
||
error[E0798]: functions with the `"C-cmse-nonsecure-entry"` ABI cannot contain generics in their type | ||
--> $DIR/generics.rs:31:1 | ||
| | ||
LL | / extern "C-cmse-nonsecure-entry" fn introduced_generic<U: Copy>( | ||
LL | | | ||
LL | | _: U, | ||
LL | | _: u32, | ||
LL | | _: u32, | ||
LL | | _: u32, | ||
LL | | ) -> u64 { | ||
| |________^ | ||
|
||
error[E0798]: functions with the `"C-cmse-nonsecure-entry"` ABI cannot contain generics in their type | ||
--> $DIR/generics.rs:41:1 | ||
| | ||
LL | extern "C-cmse-nonsecure-entry" fn impl_trait(_: impl Copy, _: u32, _: u32, _: u32) -> u64 { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0798]: functions with the `"C-cmse-nonsecure-entry"` ABI cannot contain generics in their type | ||
--> $DIR/generics.rs:15:5 | ||
| | ||
LL | extern "C-cmse-nonsecure-entry" fn ambient_generic(_: T, _: u32, _: u32, _: u32) -> u64 { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0798]: functions with the `"C-cmse-nonsecure-entry"` ABI cannot contain generics in their type | ||
--> $DIR/generics.rs:20:5 | ||
| | ||
LL | / extern "C-cmse-nonsecure-entry" fn ambient_generic_nested( | ||
LL | | | ||
LL | | _: Wrapper<T>, | ||
LL | | _: u32, | ||
LL | | _: u32, | ||
LL | | _: u32, | ||
LL | | ) -> u64 { | ||
| |____________^ | ||
|
||
error[E0798]: return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers | ||
--> $DIR/generics.rs:52:67 | ||
| | ||
LL | extern "C-cmse-nonsecure-entry" fn trait_object(x: &dyn Trait) -> &dyn Trait { | ||
| ^^^^^^^^^^ this type doesn't fit in the available registers | ||
| | ||
= note: functions with the `"C-cmse-nonsecure-entry"` ABI must pass their result via the available return registers | ||
= note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size | ||
|
||
error[E0798]: return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers | ||
--> $DIR/generics.rs:59:6 | ||
| | ||
LL | ) -> &'static dyn Trait { | ||
| ^^^^^^^^^^^^^^^^^^ this type doesn't fit in the available registers | ||
| | ||
= note: functions with the `"C-cmse-nonsecure-entry"` ABI must pass their result via the available return registers | ||
= note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size | ||
|
||
error[E0798]: return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers | ||
--> $DIR/generics.rs:69:6 | ||
| | ||
LL | ) -> WrapperTransparent { | ||
| ^^^^^^^^^^^^^^^^^^ this type doesn't fit in the available registers | ||
| | ||
= note: functions with the `"C-cmse-nonsecure-entry"` ABI must pass their result via the available return registers | ||
= note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size | ||
|
||
error: requires `va_list` lang_item | ||
--> $DIR/generics.rs:74:55 | ||
| | ||
LL | extern "C-cmse-nonsecure-entry" fn c_variadic(_: u32, _: ...) { | ||
| ^^^^^^ | ||
|
||
error: aborting due to 9 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0798`. |
Oops, something went wrong.