mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 22:41:50 +00:00
40 lines
674 B
Rust
40 lines
674 B
Rust
// This test checks that comparison operation
|
|
// generated by #[derive(PartialOrd)]
|
|
// doesn't contain jumps for C enums
|
|
|
|
// compile-flags: -Copt-level=3
|
|
|
|
#![crate_type="lib"]
|
|
|
|
#[repr(u32)]
|
|
#[derive(Copy, Clone, Eq, PartialEq, PartialOrd)]
|
|
pub enum Foo {
|
|
Zero,
|
|
One,
|
|
Two,
|
|
}
|
|
|
|
#[no_mangle]
|
|
pub fn compare_less(a: Foo, b: Foo)->bool{
|
|
// CHECK-NOT: br {{.*}}
|
|
a < b
|
|
}
|
|
|
|
#[no_mangle]
|
|
pub fn compare_le(a: Foo, b: Foo)->bool{
|
|
// CHECK-NOT: br {{.*}}
|
|
a <= b
|
|
}
|
|
|
|
#[no_mangle]
|
|
pub fn compare_ge(a: Foo, b: Foo)->bool{
|
|
// CHECK-NOT: br {{.*}}
|
|
a >= b
|
|
}
|
|
|
|
#[no_mangle]
|
|
pub fn compare_greater(a: Foo, b: Foo)->bool{
|
|
// CHECK-NOT: br {{.*}}
|
|
a > b
|
|
}
|