Skip to content

Commit c04b52a

Browse files
committed
Add regression tests
1 parent 5a6036a commit c04b52a

4 files changed

+62
-0
lines changed
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//! This is a regression test to ensure that we emit a diagnostic pointing to the
2+
//! reason the type was rejected in inline assembly.
3+
4+
//@ only-x86_64
5+
6+
#![feature(repr_simd)]
7+
8+
#[repr(simd)]
9+
#[derive(Copy, Clone)]
10+
pub struct Foo<const C: usize>([u8; C]);
11+
12+
pub unsafe fn foo<const C: usize>(a: Foo<C>) {
13+
std::arch::asm!(
14+
"movaps {src}, {src}",
15+
src = in(xmm_reg) a,
16+
//~^ ERROR: cannot use value of type `Foo<C>` for inline assembly
17+
);
18+
}
19+
20+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: cannot use value of type `Foo<C>` for inline assembly
2+
--> $DIR/generic_const_simd_vec_len.rs:15:27
3+
|
4+
LL | src = in(xmm_reg) a,
5+
| ^
6+
|
7+
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
8+
9+
error: aborting due to 1 previous error
10+
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//! This is a regression test to ensure that we evaluate
2+
//! SIMD vector length constants instead of assuming they are literals.
3+
4+
//@ only-x86_64
5+
6+
#![feature(repr_simd)]
7+
8+
const C: usize = 16;
9+
10+
#[repr(simd)]
11+
#[derive(Copy, Clone)]
12+
pub struct Foo([u8; C]);
13+
14+
pub unsafe fn foo(a: Foo) {
15+
std::arch::asm!(
16+
"movaps {src}, {src}",
17+
src = in(xmm_reg) a,
18+
//~^ ERROR: cannot use value of type `Foo` for inline assembly
19+
);
20+
}
21+
22+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: cannot use value of type `Foo` for inline assembly
2+
--> $DIR/named_const_simd_vec_len.rs:17:27
3+
|
4+
LL | src = in(xmm_reg) a,
5+
| ^
6+
|
7+
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
8+
9+
error: aborting due to 1 previous error
10+

0 commit comments

Comments
 (0)