summary refs log tree commit diff
path: root/tests/ui/abi/cannot-be-called.rs
blob: 89173655a4acf14d3c67a7215de2dd2b0ad34b67 (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//@ add-core-stubs
//@ revisions: x64 x64_win i686 riscv32 riscv64 avr msp430
//
//@ [x64] needs-llvm-components: x86
//@ [x64] compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=rlib
//@ [x64_win] needs-llvm-components: x86
//@ [x64_win] compile-flags: --target=x86_64-pc-windows-msvc --crate-type=rlib
//@ [i686] needs-llvm-components: x86
//@ [i686] compile-flags: --target=i686-unknown-linux-gnu --crate-type=rlib
//@ [riscv32] needs-llvm-components: riscv
//@ [riscv32] compile-flags: --target=riscv32i-unknown-none-elf --crate-type=rlib
//@ [riscv64] needs-llvm-components: riscv
//@ [riscv64] compile-flags: --target=riscv64gc-unknown-none-elf --crate-type=rlib
//@ [avr] needs-llvm-components: avr
//@ [avr] compile-flags: --target=avr-none -C target-cpu=atmega328p --crate-type=rlib
//@ [msp430] needs-llvm-components: msp430
//@ [msp430] compile-flags: --target=msp430-none-elf --crate-type=rlib
#![no_core]
#![feature(
    no_core,
    lang_items,
    abi_ptx,
    abi_msp430_interrupt,
    abi_avr_interrupt,
    abi_gpu_kernel,
    abi_x86_interrupt,
    abi_riscv_interrupt,
    abi_c_cmse_nonsecure_call,
    abi_vectorcall,
    cmse_nonsecure_entry
)]

extern crate minicore;
use minicore::*;

extern "msp430-interrupt" fn msp430() {}
//[x64,x64_win,i686,riscv32,riscv64,avr]~^ ERROR is not a supported ABI
extern "avr-interrupt" fn avr() {}
//[x64,x64_win,i686,riscv32,riscv64,msp430]~^ ERROR is not a supported ABI
extern "riscv-interrupt-m" fn riscv_m() {}
//[x64,x64_win,i686,avr,msp430]~^ ERROR is not a supported ABI
extern "riscv-interrupt-s" fn riscv_s() {}
//[x64,x64_win,i686,avr,msp430]~^ ERROR is not a supported ABI
extern "x86-interrupt" fn x86() {}
//[riscv32,riscv64,avr,msp430]~^ ERROR is not a supported ABI

fn call_the_interrupts() {
    msp430();
    //[msp430]~^ ERROR functions with the "msp430-interrupt" ABI cannot be called
    avr();
    //[avr]~^ ERROR functions with the "avr-interrupt" ABI cannot be called
    riscv_m();
    //[riscv32,riscv64]~^ ERROR functions with the "riscv-interrupt-m" ABI cannot be called
    riscv_s();
    //[riscv32,riscv64]~^ ERROR functions with the "riscv-interrupt-s" ABI cannot be called
    x86();
    //[x64,x64_win,i686]~^ ERROR functions with the "x86-interrupt" ABI cannot be called
}

fn msp430_ptr(f: extern "msp430-interrupt" fn()) {
    //[x64,x64_win,i686,riscv32,riscv64,avr]~^ WARN unsupported_fn_ptr_calling_conventions
    //[x64,x64_win,i686,riscv32,riscv64,avr]~^^ WARN this was previously accepted
    f()
    //[msp430]~^ ERROR functions with the "msp430-interrupt" ABI cannot be called
}

fn avr_ptr(f: extern "avr-interrupt" fn()) {
    //[x64,x64_win,i686,riscv32,riscv64,msp430]~^ WARN unsupported_fn_ptr_calling_conventions
    //[x64,x64_win,i686,riscv32,riscv64,msp430]~^^ WARN this was previously accepted
    f()
    //[avr]~^ ERROR functions with the "avr-interrupt" ABI cannot be called
}

fn riscv_m_ptr(f: extern "riscv-interrupt-m" fn()) {
    //[x64,x64_win,i686,avr,msp430]~^ WARN unsupported_fn_ptr_calling_conventions
    //[x64,x64_win,i686,avr,msp430]~^^ WARN this was previously accepted
    f()
    //[riscv32,riscv64]~^ ERROR functions with the "riscv-interrupt-m" ABI cannot be called
}

fn riscv_s_ptr(f: extern "riscv-interrupt-s" fn()) {
    //[x64,x64_win,i686,avr,msp430]~^ WARN unsupported_fn_ptr_calling_conventions
    //[x64,x64_win,i686,avr,msp430]~^^ WARN this was previously accepted
    f()
    //[riscv32,riscv64]~^ ERROR functions with the "riscv-interrupt-s" ABI cannot be called
}

fn x86_ptr(f: extern "x86-interrupt" fn()) {
    //[riscv32,riscv64,avr,msp430]~^ WARN unsupported_fn_ptr_calling_conventions
    //[riscv32,riscv64,avr,msp430]~^^ WARN this was previously accepted
    f()
    //[x64,x64_win,i686]~^ ERROR functions with the "x86-interrupt" ABI cannot be called
}