]> git.lizzy.rs Git - rust.git/blob - tests/codegen/enum-bounds-check-issue-13926.rs
Auto merge of #107843 - bjorn3:sync_cg_clif-2023-02-09, r=bjorn3
[rust.git] / tests / codegen / enum-bounds-check-issue-13926.rs
1 // This test checks an optimization that is not guaranteed to work. This test case should not block
2 // a future LLVM update.
3 // compile-flags: -O
4
5 #![crate_type = "lib"]
6
7 #[repr(u8)]
8 pub enum Exception {
9     Low = 5,
10     High = 10,
11 }
12
13 // CHECK-LABEL: @access
14 #[no_mangle]
15 pub fn access(array: &[usize; 12], exc: Exception) -> usize {
16     // CHECK-NOT: panic_bounds_check
17     array[(exc as u8 - 4) as usize]
18 }