Skip to content

Commit 3440505

Browse files
committed
add vector ABI check test for calling extern fn
1 parent b9a0e57 commit 3440505

File tree

2 files changed

+61
-11
lines changed

2 files changed

+61
-11
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

+44-10
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,11 +109,11 @@ 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

104114
Future incompatibility report: Future breakage diagnostic:
105115
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
106-
--> $DIR/simd-abi-checks.rs:55:11
116+
--> $DIR/simd-abi-checks.rs:64:11
107117
|
108118
LL | f(g());
109119
| ^^^ function called here
@@ -115,7 +125,7 @@ LL | f(g());
115125

116126
Future breakage diagnostic:
117127
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
118-
--> $DIR/simd-abi-checks.rs:55:9
128+
--> $DIR/simd-abi-checks.rs:64:9
119129
|
120130
LL | f(g());
121131
| ^^^^^^ function called here
@@ -127,7 +137,7 @@ LL | f(g());
127137

128138
Future breakage diagnostic:
129139
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
130-
--> $DIR/simd-abi-checks.rs:63:14
140+
--> $DIR/simd-abi-checks.rs:72:14
131141
|
132142
LL | gavx(favx());
133143
| ^^^^^^ function called here
@@ -139,7 +149,7 @@ LL | gavx(favx());
139149

140150
Future breakage diagnostic:
141151
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
142-
--> $DIR/simd-abi-checks.rs:63:9
152+
--> $DIR/simd-abi-checks.rs:72:9
143153
|
144154
LL | gavx(favx());
145155
| ^^^^^^^^^^^^ function called here
@@ -151,7 +161,7 @@ LL | gavx(favx());
151161

152162
Future breakage diagnostic:
153163
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
154-
--> $DIR/simd-abi-checks.rs:75:19
164+
--> $DIR/simd-abi-checks.rs:84:19
155165
|
156166
LL | w(Wrapper(g()));
157167
| ^^^ function called here
@@ -163,7 +173,7 @@ LL | w(Wrapper(g()));
163173

164174
Future breakage diagnostic:
165175
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
166-
--> $DIR/simd-abi-checks.rs:75:9
176+
--> $DIR/simd-abi-checks.rs:84:9
167177
|
168178
LL | w(Wrapper(g()));
169179
| ^^^^^^^^^^^^^^^ function called here
@@ -173,9 +183,21 @@ LL | w(Wrapper(g()));
173183
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
174184
= note: `#[warn(abi_unsupported_vector_types)]` on by default
175185

186+
Future breakage diagnostic:
187+
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
188+
--> $DIR/simd-abi-checks.rs:100:9
189+
|
190+
LL | some_extern();
191+
| ^^^^^^^^^^^^^ function called here
192+
|
193+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
194+
= note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558>
195+
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
196+
= note: `#[warn(abi_unsupported_vector_types)]` on by default
197+
176198
Future breakage diagnostic:
177199
warning: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled
178-
--> $DIR/simd-abi-checks.rs:26:1
200+
--> $DIR/simd-abi-checks.rs:27:1
179201
|
180202
LL | unsafe extern "C" fn g() -> __m256 {
181203
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here
@@ -187,7 +209,7 @@ LL | unsafe extern "C" fn g() -> __m256 {
187209

188210
Future breakage diagnostic:
189211
warning: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled
190-
--> $DIR/simd-abi-checks.rs:20:1
212+
--> $DIR/simd-abi-checks.rs:21:1
191213
|
192214
LL | unsafe extern "C" fn f(_: __m256) {
193215
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here
@@ -199,7 +221,7 @@ LL | unsafe extern "C" fn f(_: __m256) {
199221

200222
Future breakage diagnostic:
201223
warning: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled
202-
--> $DIR/simd-abi-checks.rs:14:1
224+
--> $DIR/simd-abi-checks.rs:15:1
203225
|
204226
LL | unsafe extern "C" fn w(_: Wrapper) {
205227
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here
@@ -209,3 +231,15 @@ LL | unsafe extern "C" fn w(_: Wrapper) {
209231
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
210232
= note: `#[warn(abi_unsupported_vector_types)]` on by default
211233

234+
Future breakage diagnostic:
235+
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
236+
--> $DIR/simd-abi-checks.rs:57:8
237+
|
238+
LL | || g()
239+
| ^^^ function called here
240+
|
241+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
242+
= note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558>
243+
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
244+
= note: `#[warn(abi_unsupported_vector_types)]` on by default
245+

0 commit comments

Comments
 (0)