gcc/testsuite/rust/execute/torture/match_int1.rs
raw| 1 | // { dg-output "other!\r*\nother!\r*\nother!\r*\nfifteen!\r*\nfifteen!\r*\nother!\r*\nother!\r*\nfifteen!\r*\n" } |
| 2 | |
| 3 | extern "C" { |
| 4 | fn printf(s: *const i8, ...); |
| 5 | } |
| 6 | |
| 7 | fn foo_i32(x: i32) { |
| 8 | match x { |
| 9 | 15 => { |
| 10 | let a = "fifteen!\n\0"; |
| 11 | let b = a as *const str; |
| 12 | let c = b as *const i8; |
| 13 | unsafe { |
| 14 | printf(c); |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | _ => { |
| 19 | let a = "other!\n\0"; |
| 20 | let b = a as *const str; |
| 21 | let c = b as *const i8; |
| 22 | unsafe { |
| 23 | printf(c); |
| 24 | } |
| 25 | } |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | fn foo_isize(x: isize) { |
| 30 | match x { |
| 31 | 15 => { |
| 32 | let a = "fifteen!\n\0"; |
| 33 | let b = a as *const str; |
| 34 | let c = b as *const i8; |
| 35 | unsafe { |
| 36 | printf(c); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | _ => { |
| 41 | let a = "other!\n\0"; |
| 42 | let b = a as *const str; |
| 43 | let c = b as *const i8; |
| 44 | unsafe { |
| 45 | printf(c); |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | fn foo_u32(x: u32) { |
| 52 | match x { |
| 53 | 15 => { |
| 54 | let a = "fifteen!\n\0"; |
| 55 | let b = a as *const str; |
| 56 | let c = b as *const i8; |
| 57 | unsafe { |
| 58 | printf(c); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | _ => { |
| 63 | let a = "other!\n\0"; |
| 64 | let b = a as *const str; |
| 65 | let c = b as *const i8; |
| 66 | unsafe { |
| 67 | printf(c); |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | fn foo_usize(x: usize) { |
| 74 | match x { |
| 75 | 15 => { |
| 76 | let a = "fifteen!\n\0"; |
| 77 | let b = a as *const str; |
| 78 | let c = b as *const i8; |
| 79 | unsafe { |
| 80 | printf(c); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | _ => { |
| 85 | let a = "other!\n\0"; |
| 86 | let b = a as *const str; |
| 87 | let c = b as *const i8; |
| 88 | unsafe { |
| 89 | printf(c); |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | fn main() -> i32 { |
| 96 | let x = -2; |
| 97 | foo_i32(x); |
| 98 | foo_i32(334); |
| 99 | foo_isize(-4768); |
| 100 | foo_isize(15); |
| 101 | |
| 102 | let y = 127; |
| 103 | foo_u32(15); |
| 104 | foo_u32(y); |
| 105 | foo_usize(2394); |
| 106 | foo_usize(15); |
| 107 | |
| 108 | 0 |
| 109 | } |