gcc/testsuite/rust/execute/torture/match_loop1.rs
raw| 1 | // { dg-output "E::One\r*\nE::Two\r*\nbreak!\r*\n" } |
| 2 | |
| 3 | extern "C" { |
| 4 | fn printf(s: *const i8, ...); |
| 5 | } |
| 6 | |
| 7 | enum E { |
| 8 | One, |
| 9 | Two, |
| 10 | Other, |
| 11 | } |
| 12 | |
| 13 | fn foo() { |
| 14 | let mut x = E::One; |
| 15 | |
| 16 | loop { |
| 17 | match x { |
| 18 | E::One => { |
| 19 | let a = "E::One\n\0"; |
| 20 | let b = a as *const str; |
| 21 | let c = b as *const i8; |
| 22 | unsafe { |
| 23 | printf(c); |
| 24 | } |
| 25 | |
| 26 | x = E::Two; |
| 27 | } |
| 28 | E::Two => { |
| 29 | let a = "E::Two\n\0"; |
| 30 | let b = a as *const str; |
| 31 | let c = b as *const i8; |
| 32 | unsafe { |
| 33 | printf(c); |
| 34 | } |
| 35 | |
| 36 | x = E::Other; |
| 37 | } |
| 38 | _ => { |
| 39 | let a = "break!\n\0"; |
| 40 | let b = a as *const str; |
| 41 | let c = b as *const i8; |
| 42 | unsafe { |
| 43 | printf(c); |
| 44 | } |
| 45 | |
| 46 | break; |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | fn main() -> i32 { |
| 53 | foo(); |
| 54 | |
| 55 | 0 |
| 56 | } |