diff options
Diffstat (limited to 'src/test/ui/unwind-abis/ffi-unwind-calls-lint.rs')
-rw-r--r-- | src/test/ui/unwind-abis/ffi-unwind-calls-lint.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/ui/unwind-abis/ffi-unwind-calls-lint.rs b/src/test/ui/unwind-abis/ffi-unwind-calls-lint.rs new file mode 100644 index 000000000..dadf4b121 --- /dev/null +++ b/src/test/ui/unwind-abis/ffi-unwind-calls-lint.rs @@ -0,0 +1,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 +} |