Skip to content

Commit

Permalink
add test for #52334
Browse files Browse the repository at this point in the history
Fixes #52334
  • Loading branch information
matthiaskrgr committed Mar 24, 2024
1 parent 548e14b commit 14d05c4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/ui/extern/extern-C-non-FFI-safe-arg-ice-52334.rs
Original file line number Diff line number Diff line change
@@ -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;
}
22 changes: 22 additions & 0 deletions tests/ui/extern/extern-C-non-FFI-safe-arg-ice-52334.stderr
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 14d05c4

Please sign in to comment.