2021-04-03 12:58:15 -05:00
|
|
|
// This test checks that comparison operation
|
|
|
|
// generated by #[derive(PartialOrd)]
|
|
|
|
// doesn't contain jumps for C enums
|
|
|
|
|
|
|
|
//@ compile-flags: -Copt-level=3
|
|
|
|
|
2024-05-28 23:11:20 -05:00
|
|
|
#![crate_type = "lib"]
|
2021-04-03 12:58:15 -05:00
|
|
|
|
|
|
|
#[repr(u32)]
|
|
|
|
#[derive(Copy, Clone, Eq, PartialEq, PartialOrd)]
|
|
|
|
pub enum Foo {
|
|
|
|
Zero,
|
|
|
|
One,
|
|
|
|
Two,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
2024-05-28 23:11:20 -05:00
|
|
|
pub fn compare_less(a: Foo, b: Foo) -> bool {
|
2021-04-03 12:58:15 -05:00
|
|
|
// CHECK-NOT: br {{.*}}
|
|
|
|
a < b
|
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
2024-05-28 23:11:20 -05:00
|
|
|
pub fn compare_le(a: Foo, b: Foo) -> bool {
|
2021-04-03 12:58:15 -05:00
|
|
|
// CHECK-NOT: br {{.*}}
|
|
|
|
a <= b
|
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
2024-05-28 23:11:20 -05:00
|
|
|
pub fn compare_ge(a: Foo, b: Foo) -> bool {
|
2021-04-03 12:58:15 -05:00
|
|
|
// CHECK-NOT: br {{.*}}
|
|
|
|
a >= b
|
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
2024-05-28 23:11:20 -05:00
|
|
|
pub fn compare_greater(a: Foo, b: Foo) -> bool {
|
2021-04-03 12:58:15 -05:00
|
|
|
// CHECK-NOT: br {{.*}}
|
|
|
|
a > b
|
|
|
|
}
|