Fix ICE for repr simd on non struct
This commit is contained in:
parent
c90bcb9571
commit
112d833ea5
3 changed files with 54 additions and 0 deletions
|
|
@ -93,6 +93,14 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
ty::Adt(adt, args) if adt.repr().simd() => {
|
||||
if !adt.is_struct() {
|
||||
self.fcx.dcx().span_delayed_bug(
|
||||
span,
|
||||
format!("repr(simd) should only be used on structs, got {}", adt.descr()),
|
||||
);
|
||||
return Err(NonAsmTypeReason::Invalid(ty));
|
||||
}
|
||||
|
||||
let fields = &adt.non_enum_variant().fields;
|
||||
if fields.is_empty() {
|
||||
return Err(NonAsmTypeReason::EmptySIMDArray(ty));
|
||||
|
|
|
|||
16
tests/ui/asm/invalid-repr-simd-on-enum-148634.rs
Normal file
16
tests/ui/asm/invalid-repr-simd-on-enum-148634.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#![feature(repr_simd)]
|
||||
|
||||
use std::arch::asm;
|
||||
|
||||
#[repr(simd)]
|
||||
//~^ ERROR attribute should be applied to a struct
|
||||
//~| ERROR unsupported representation for zero-variant enum
|
||||
enum Es {}
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
let mut x: Es;
|
||||
asm!("{}", out(reg) x);
|
||||
//~^ ERROR cannot use value of type `Es` for inline assembly
|
||||
}
|
||||
}
|
||||
30
tests/ui/asm/invalid-repr-simd-on-enum-148634.stderr
Normal file
30
tests/ui/asm/invalid-repr-simd-on-enum-148634.stderr
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
error[E0517]: attribute should be applied to a struct
|
||||
--> $DIR/invalid-repr-simd-on-enum-148634.rs:5:8
|
||||
|
|
||||
LL | #[repr(simd)]
|
||||
| ^^^^
|
||||
...
|
||||
LL | enum Es {}
|
||||
| ---------- not a struct
|
||||
|
||||
error[E0084]: unsupported representation for zero-variant enum
|
||||
--> $DIR/invalid-repr-simd-on-enum-148634.rs:5:8
|
||||
|
|
||||
LL | #[repr(simd)]
|
||||
| ^^^^
|
||||
...
|
||||
LL | enum Es {}
|
||||
| ------- zero-variant enum
|
||||
|
||||
error: cannot use value of type `Es` for inline assembly
|
||||
--> $DIR/invalid-repr-simd-on-enum-148634.rs:13:29
|
||||
|
|
||||
LL | asm!("{}", out(reg) x);
|
||||
| ^
|
||||
|
|
||||
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0084, E0517.
|
||||
For more information about an error, try `rustc --explain E0084`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue