summaryrefslogtreecommitdiffstats
path: root/src/test/ui/unwind-abis/ffi-unwind-calls-lint.rs
blob: dadf4b1218784bc04fd5fbe65a6a2d213954aa42 (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
// build-pass
// needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default

#![feature(c_unwind)]
#![warn(ffi_unwind_calls)]

mod foo {
    #[no_mangle]
    pub extern "C-unwind" fn foo() {}
}

extern "C-unwind" {
    fn foo();
}

fn main() {
    // Call to Rust function is fine.
    foo::foo();
    // Call to foreign function should warn.
    unsafe { foo(); }
    //~^ WARNING call to foreign function with FFI-unwind ABI
    let ptr: extern "C-unwind" fn() = foo::foo;
    // Call to function pointer should also warn.
    ptr();
    //~^ WARNING call to function pointer with FFI-unwind ABI
}