add test for #52334

Fixes #52334
This commit is contained in:
Matthias Krüger 2024-03-22 17:49:04 +01:00
parent 548e14b439
commit 14d05c4c4b
2 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,13 @@
// test for #52334 ICE when casting extern "C" fn when it has a non-FFI-safe argument
//@ check-pass
type Foo = extern "C" fn(::std::ffi::CStr);
//~^ WARN `extern` fn uses type `[i8]`, which is not FFI-safe
extern "C" {
fn meh(blah: Foo);
//~^ WARN `extern` block uses type `[i8]`, which is not FFI-safe
}
fn main() {
meh as usize;
}

View File

@ -0,0 +1,22 @@
warning: `extern` fn uses type `[i8]`, which is not FFI-safe
--> $DIR/extern-C-non-FFI-safe-arg-ice-52334.rs:4:12
|
LL | type Foo = extern "C" fn(::std::ffi::CStr);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
|
= help: consider using a raw pointer instead
= note: slices have no C equivalent
= note: `#[warn(improper_ctypes_definitions)]` on by default
warning: `extern` block uses type `[i8]`, which is not FFI-safe
--> $DIR/extern-C-non-FFI-safe-arg-ice-52334.rs:7:18
|
LL | fn meh(blah: Foo);
| ^^^ not FFI-safe
|
= help: consider using a raw pointer instead
= note: slices have no C equivalent
= note: `#[warn(improper_ctypes)]` on by default
warning: 2 warnings emitted