diff --git a/tests/ui/asm/generic_const_simd_vec_len.rs b/tests/ui/asm/generic_const_simd_vec_len.rs new file mode 100644 index 00000000000..d3b60abf05a --- /dev/null +++ b/tests/ui/asm/generic_const_simd_vec_len.rs @@ -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([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() {} diff --git a/tests/ui/asm/generic_const_simd_vec_len.stderr b/tests/ui/asm/generic_const_simd_vec_len.stderr new file mode 100644 index 00000000000..7e7a3c9401c --- /dev/null +++ b/tests/ui/asm/generic_const_simd_vec_len.stderr @@ -0,0 +1,10 @@ +error: cannot use value of type `Foo` 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 + diff --git a/tests/ui/asm/named_const_simd_vec_len.rs b/tests/ui/asm/named_const_simd_vec_len.rs new file mode 100644 index 00000000000..8f2159077fc --- /dev/null +++ b/tests/ui/asm/named_const_simd_vec_len.rs @@ -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() {} diff --git a/tests/ui/asm/named_const_simd_vec_len.stderr b/tests/ui/asm/named_const_simd_vec_len.stderr new file mode 100644 index 00000000000..184cc2b05e2 --- /dev/null +++ b/tests/ui/asm/named_const_simd_vec_len.stderr @@ -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 +