Skip to content

Commit

Permalink
add vector ABI check test for calling extern fn
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Nov 23, 2024
1 parent 214b634 commit 134f13b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
18 changes: 17 additions & 1 deletion tests/ui/simd-abi-checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#![feature(avx512_target_feature)]
#![feature(portable_simd)]
#![feature(target_feature_11)]
#![feature(target_feature_11, simd_ffi)]
#![allow(improper_ctypes_definitions)]

use std::arch::x86_64::*;
Expand Down Expand Up @@ -91,4 +91,20 @@ fn main() {
unsafe {
in_closure()();
}

unsafe {
#[expect(improper_ctypes)]
extern "C" {
fn some_extern() -> __m256;
}
some_extern();
//~^ WARNING this function call uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller
//~| WARNING this was previously accepted by the compiler
}
}

#[no_mangle]
#[target_feature(enable = "avx")]
fn some_extern() -> __m256 {
todo!()
}
12 changes: 11 additions & 1 deletion tests/ui/simd-abi-checks.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ LL | w(Wrapper(g()));
= note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558>
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)

warning: this function call uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller
--> $DIR/simd-abi-checks.rs:100:9
|
LL | some_extern();
| ^^^^^^^^^^^^^ function called here
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558>
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)

warning: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled
--> $DIR/simd-abi-checks.rs:27:1
|
Expand Down Expand Up @@ -99,5 +109,5 @@ LL | || g()
= note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558>
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)

warning: 10 warnings emitted
warning: 11 warnings emitted

0 comments on commit 134f13b

Please sign in to comment.