Debian Codegraph @

gcc/testsuite/rust/execute/torture/match_byte1.rs

raw
1 // { dg-output "a\r*\nseven\r*\nquote\r*\nelse" }
2
3 extern "C" {
4 fn printf(s: *const i8, ...);
5 }
6
7 fn foo(x: u8) {
8 match x {
9 b'a' => {
10 let a = "a\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 b'\x07' => {
19 let a = "seven\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 b'\'' => {
28 let a = "quote\n\0";
29 let b = a as *const str;
30 let c = b as *const i8;
31 unsafe {
32 printf(c);
33 }
34 }
35
36 _ => {
37 let a = "else\n\0";
38 let b = a as *const str;
39 let c = b as *const i8;
40 unsafe {
41 printf(c);
42 }
43 }
44 }
45 }
46
47 fn main() -> i32 {
48 let x: u8 = 7;
49
50 foo(b'a');
51 foo(x);
52 foo(b'\'');
53 foo(b'\\');
54
55 0
56 }