gccrs: Add execution test cases
[official-gcc.git] / gcc / testsuite / rust / execute / torture / match_tuple1.rs
blobcb61cc0847c05e10bcbab3a3b90617ff9a3a5c29
1 // { dg-output "x:15\ny:20\n" }
3 extern "C" {
4     fn printf(s: *const i8, ...);
7 enum Foo {
8     A,
9     B,
12 fn inspect(f: Foo, g: u8) -> i32 {
13     match (f, g) {
14         (Foo::A, 1) => {
15             return 5;
16         }
18         (Foo::A, 2) => {
19             return 10;
20         }
22         (Foo::B, 2) => {
23             return 15;
24         }
26         _ => {
27             return 20;
28         }
29     }
30     return 25;
33 fn main() -> i32 {
34     let x = inspect(Foo::B, 2);
35     let y = inspect(Foo::B, 1);
37     unsafe {
38         printf("x:%d\n" as *const str as *const i8, x);
39     }
40     unsafe {
41         printf("y:%d\n" as *const str as *const i8, y);
42     }
44     y - x - 5