Add test for updating enum discriminant through pointer

This commit is contained in:
clubby789 2024-08-01 15:41:17 +00:00
parent c0e32983f5
commit 8497800abd

View File

@ -0,0 +1,19 @@
//@ compile-flags: -O
//@ min-llvm-version: 19
#![crate_type = "lib"]
pub enum State {
A([u8; 753]),
B([u8; 753]),
}
// CHECK-LABEL: @update
#[no_mangle]
pub unsafe fn update(s: *mut State) {
// CHECK-NEXT: start:
// CHECK-NEXT: store i8
// CHECK-NEXT: ret
let State::A(v) = s.read() else { std::hint::unreachable_unchecked() };
s.write(State::B(v));
}