cmse: add test for async and const functions

async functions are disallowed (because `-> impl Trait` is not supported). `const` entry functions are allowed, nonsecure-call functions must be function pointers, which cannot be evaluated during constant evaluation.
This commit is contained in:
Folkert de Vries 2025-11-05 17:06:39 +01:00
parent 8e0b68e63c
commit 4e9dfb5d3b
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
3 changed files with 23 additions and 1 deletions

View file

@ -21,6 +21,11 @@ async unsafe extern "cmse-nonsecure-entry" fn async_and_c_variadic(_: ...) {
//~| ERROR functions cannot be both `async` and C-variadic
}
// Async on its own is also not allowed.
async unsafe extern "cmse-nonsecure-entry" fn async_is_not_allowed() {
//~^ ERROR `impl Trait` is not allowed in `extern "cmse-nonsecure-entry"` signatures
}
// Below are the lang items that are required for a program that defines an `async` function.
// Without them, the ICE that is tested for here is not reached for this target. For now they are in
// this file, but they may be moved into `minicore` if/when other `#[no_core]` tests want to use

View file

@ -24,5 +24,12 @@ LL | async unsafe extern "cmse-nonsecure-entry" fn async_and_c_variadic(_: ...)
|
= help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list
error: aborting due to 3 previous errors
error[E0798]: `impl Trait` is not allowed in `extern "cmse-nonsecure-entry"` signatures
--> $DIR/c-variadic.rs:25:1
|
LL | async unsafe extern "cmse-nonsecure-entry" fn async_is_not_allowed() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0798`.

View file

@ -89,3 +89,13 @@ extern "cmse-nonsecure-entry" fn identity_impl_trait_nested(
//~^ ERROR `impl Trait` is not allowed in `extern "cmse-nonsecure-entry"` signatures
v
}
const extern "cmse-nonsecure-entry" fn const_fn_works(x: u8) -> u8 {
x
}
const CONST: u8 = const_fn_works(0);
fn fn_ptr_works(f: extern "cmse-nonsecure-entry" fn(_: u8) -> u8) -> u8 {
f(0)
}