Skip to content

Commit

Permalink
Add regression tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Dec 11, 2024
1 parent 5a6036a commit c04b52a
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/ui/asm/generic_const_simd_vec_len.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//! This is a regression test to ensure that we emit a diagnostic pointing to the
//! reason the type was rejected in inline assembly.
//@ only-x86_64

#![feature(repr_simd)]

#[repr(simd)]
#[derive(Copy, Clone)]
pub struct Foo<const C: usize>([u8; C]);

pub unsafe fn foo<const C: usize>(a: Foo<C>) {
std::arch::asm!(
"movaps {src}, {src}",
src = in(xmm_reg) a,
//~^ ERROR: cannot use value of type `Foo<C>` for inline assembly
);
}

fn main() {}
10 changes: 10 additions & 0 deletions tests/ui/asm/generic_const_simd_vec_len.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: cannot use value of type `Foo<C>` for inline assembly
--> $DIR/generic_const_simd_vec_len.rs:15:27
|
LL | src = in(xmm_reg) a,
| ^
|
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly

error: aborting due to 1 previous error

22 changes: 22 additions & 0 deletions tests/ui/asm/named_const_simd_vec_len.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//! This is a regression test to ensure that we evaluate
//! SIMD vector length constants instead of assuming they are literals.
//@ only-x86_64

#![feature(repr_simd)]

const C: usize = 16;

#[repr(simd)]
#[derive(Copy, Clone)]
pub struct Foo([u8; C]);

pub unsafe fn foo(a: Foo) {
std::arch::asm!(
"movaps {src}, {src}",
src = in(xmm_reg) a,
//~^ ERROR: cannot use value of type `Foo` for inline assembly
);
}

fn main() {}
10 changes: 10 additions & 0 deletions tests/ui/asm/named_const_simd_vec_len.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: cannot use value of type `Foo` for inline assembly
--> $DIR/named_const_simd_vec_len.rs:17:27
|
LL | src = in(xmm_reg) a,
| ^
|
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly

error: aborting due to 1 previous error

0 comments on commit c04b52a

Please sign in to comment.