Skip to content

Commit fe605b9

Browse files
committed
Add regression tests
1 parent 1b3fb31 commit fe605b9

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
#![feature(repr_simd)]
5+
6+
#[repr(simd)]
7+
#[derive(Copy, Clone)]
8+
pub struct Foo<const C: usize>([u8; C]);
9+
10+
pub unsafe fn foo<const C: usize>(a: Foo<C>) {
11+
std::arch::asm!(
12+
"movaps {src}, {src}",
13+
src = in(xmm_reg) a,
14+
//~^ ERROR: cannot use value of type `Foo<C>` for inline assembly
15+
);
16+
}
17+
18+
fn main() {}
Lines changed: 10 additions & 0 deletions
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:13: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+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//! This is a regression test to ensure that we evaluate
2+
//! SIMD vector length constants instead of assuming they are literals.
3+
4+
#![feature(repr_simd)]
5+
6+
const C: usize = 16;
7+
8+
#[repr(simd)]
9+
#[derive(Copy, Clone)]
10+
pub struct Foo([u8; C]);
11+
12+
pub unsafe fn foo(a: Foo) {
13+
std::arch::asm!(
14+
"movaps {src}, {src}",
15+
src = in(xmm_reg) a,
16+
//~^ ERROR: cannot use value of type `Foo` for inline assembly
17+
);
18+
}
19+
20+
fn main() {}
Lines changed: 10 additions & 0 deletions
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: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+

0 commit comments

Comments
 (0)