Debian Codegraph @

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

raw
1 // { dg-output "amazing\r*\nwildcard\r*\ncompiler\r*\nproductivity\r*\n" }
2
3 extern "C" {
4 fn printf(s: *const i8, ...);
5 }
6
7 fn foo(x: char) {
8 match x {
9 'a' => {
10 let a = "amazing\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 'c' => {
19 let a = "compiler\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 'p' => {
28 let a = "productivity\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 = "wildcard\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 p = 'p';
49
50 foo('a');
51 foo('b');
52 foo('c');
53 foo(p);
54
55 0
56 }