Skip to content

Commit 134f13b

Browse files
committed
add vector ABI check test for calling extern fn
1 parent 214b634 commit 134f13b

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

tests/ui/simd-abi-checks.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#![feature(avx512_target_feature)]
66
#![feature(portable_simd)]
7-
#![feature(target_feature_11)]
7+
#![feature(target_feature_11, simd_ffi)]
88
#![allow(improper_ctypes_definitions)]
99

1010
use std::arch::x86_64::*;
@@ -91,4 +91,20 @@ fn main() {
9191
unsafe {
9292
in_closure()();
9393
}
94+
95+
unsafe {
96+
#[expect(improper_ctypes)]
97+
extern "C" {
98+
fn some_extern() -> __m256;
99+
}
100+
some_extern();
101+
//~^ 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
102+
//~| WARNING this was previously accepted by the compiler
103+
}
104+
}
105+
106+
#[no_mangle]
107+
#[target_feature(enable = "avx")]
108+
fn some_extern() -> __m256 {
109+
todo!()
94110
}

tests/ui/simd-abi-checks.stderr

+11-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ LL | w(Wrapper(g()));
5959
= note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558>
6060
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
6161

62+
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
63+
--> $DIR/simd-abi-checks.rs:100:9
64+
|
65+
LL | some_extern();
66+
| ^^^^^^^^^^^^^ function called here
67+
|
68+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
69+
= note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558>
70+
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
71+
6272
warning: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled
6373
--> $DIR/simd-abi-checks.rs:27:1
6474
|
@@ -99,5 +109,5 @@ LL | || g()
99109
= note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558>
100110
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
101111

102-
warning: 10 warnings emitted
112+
warning: 11 warnings emitted
103113

0 commit comments

Comments
 (0)