Rollup merge of #135295 - eyraudh:master, r=compiler-errors
Check empty SIMD vector in inline asm fixes [#134334](https://github.com/rust-lang/rust/issues/134334)
This commit is contained in:
commit
bae53a7c3c
4 changed files with 38 additions and 9 deletions
|
@ -29,6 +29,7 @@ enum NonAsmTypeReason<'tcx> {
|
|||
Invalid(Ty<'tcx>),
|
||||
InvalidElement(DefId, Ty<'tcx>),
|
||||
NotSizedPtr(Ty<'tcx>),
|
||||
EmptySIMDArray(Ty<'tcx>),
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
||||
|
@ -102,6 +103,9 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
|||
}
|
||||
ty::Adt(adt, args) if adt.repr().simd() => {
|
||||
let fields = &adt.non_enum_variant().fields;
|
||||
if fields.is_empty() {
|
||||
return Err(NonAsmTypeReason::EmptySIMDArray(ty));
|
||||
}
|
||||
let field = &fields[FieldIdx::ZERO];
|
||||
let elem_ty = field.ty(self.tcx(), args);
|
||||
|
||||
|
@ -226,6 +230,10 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
|||
can be used as arguments for inline assembly",
|
||||
).emit();
|
||||
}
|
||||
NonAsmTypeReason::EmptySIMDArray(ty) => {
|
||||
let msg = format!("use of empty SIMD vector `{ty}`");
|
||||
self.infcx.dcx().struct_span_err(expr.span, msg).emit();
|
||||
}
|
||||
}
|
||||
return None;
|
||||
}
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
//@ known-bug: #134334
|
||||
//@ only-x86_64
|
||||
|
||||
#[repr(simd)]
|
||||
struct A();
|
||||
|
||||
fn main() {
|
||||
std::arch::asm!("{}", in(xmm_reg) A());
|
||||
}
|
15
tests/ui/simd/empty-simd-vector-in-operand.rs
Normal file
15
tests/ui/simd/empty-simd-vector-in-operand.rs
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Regression test for issue #134224.
|
||||
//@ only-x86_64
|
||||
|
||||
#![feature(repr_simd)]
|
||||
|
||||
#[repr(simd)]
|
||||
struct A();
|
||||
//~^ ERROR SIMD vector cannot be empty
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
std::arch::asm!("{}", in(xmm_reg) A());
|
||||
//~^ use of empty SIMD vector `A`
|
||||
}
|
||||
}
|
15
tests/ui/simd/empty-simd-vector-in-operand.stderr
Normal file
15
tests/ui/simd/empty-simd-vector-in-operand.stderr
Normal file
|
@ -0,0 +1,15 @@
|
|||
error[E0075]: SIMD vector cannot be empty
|
||||
--> $DIR/empty-simd-vector-in-operand.rs:7:1
|
||||
|
|
||||
LL | struct A();
|
||||
| ^^^^^^^^
|
||||
|
||||
error: use of empty SIMD vector `A`
|
||||
--> $DIR/empty-simd-vector-in-operand.rs:12:43
|
||||
|
|
||||
LL | std::arch::asm!("{}", in(xmm_reg) A());
|
||||
| ^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0075`.
|
Loading…
Add table
Add a link
Reference in a new issue