]> git.proxmox.com Git - rustc.git/blame - tests/codegen/issue-77812.rs
New upstream version 1.69.0+dfsg1
[rustc.git] / tests / codegen / issue-77812.rs
CommitLineData
6a06907d
XL
1// compile-flags: -O
2#![crate_type = "lib"]
3
4// Test that LLVM can eliminate the unreachable `Variant::Zero` branch.
5
6#[derive(Copy, Clone, Eq, PartialEq)]
7pub enum Variant {
8 Zero,
9 One,
10 Two,
11}
12
13extern {
14 fn exf1();
15 fn exf2();
16}
17
18pub static mut GLOBAL: Variant = Variant::Zero;
19
20// CHECK-LABEL: @issue_77812
21#[no_mangle]
22pub unsafe fn issue_77812() {
23 let g = GLOBAL;
24 if g != Variant::Zero {
25 match g {
26 Variant::One => exf1(),
27 Variant::Two => exf2(),
28 // CHECK-NOT: panic
29 Variant::Zero => panic!(),
30 }
31 }
32}