about summary refs log tree commit diff
path: root/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/c-variadic.rs
blob: 9317ab5cd2756f5c0fc8e037f3307cdd500d6889 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//@ add-core-stubs
//@ edition: 2018
//@ 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]

extern crate minicore;
use minicore::*;

#[lang = "va_list"]
struct VaList(*mut u8);

unsafe extern "cmse-nonsecure-entry" fn c_variadic(_: u32, _: ...) {
    //~^ ERROR `...` is not supported for `extern "cmse-nonsecure-entry"` functions
}

// A regression test for https://github.com/rust-lang/rust/issues/132142
async unsafe extern "cmse-nonsecure-entry" fn async_and_c_variadic(_: ...) {
    //~^ ERROR `...` is not supported for `extern "cmse-nonsecure-entry"` functions
    //~| ERROR functions cannot be both `async` and C-variadic
}

// 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
// them.

// NOTE: in `core` this type uses `NonNull`.
#[lang = "ResumeTy"]
pub struct ResumeTy(*mut Context<'static>);

#[lang = "future_trait"]
pub trait Future {
    /// The type of value produced on completion.
    #[lang = "future_output"]
    type Output;

    // NOTE: misses the `poll` method.
}

#[lang = "async_drop"]
pub trait AsyncDrop {
    // NOTE: misses the `drop` method.
}

#[lang = "Poll"]
pub enum Poll<T> {
    #[lang = "Ready"]
    Ready(T),

    #[lang = "Pending"]
    Pending,
}

#[lang = "Context"]
pub struct Context<'a> {
    // NOTE: misses a bunch of fields.
    _marker: PhantomData<fn(&'a ()) -> &'a ()>,
}

#[lang = "get_context"]
pub unsafe fn get_context<'a, 'b>(cx: ResumeTy) -> &'a mut Context<'b> {
    // NOTE: the actual implementation looks different.
    mem::transmute(cx.0)
}

#[lang = "pin"]
pub struct Pin<T>(T);