Skip to content

Commit 6f92d79

Browse files
VillosseP-E-P
authored andcommitted
testsuite: Adds test from issue 1245
Added the test from the issue 1245. Fixes GCC-Rust/gccrs#1245 gcc/testsuite/ChangeLog: * rust/execute/issue-1245.rs: New test. Signed-off-by: lenny.chiadmi-delage <[email protected]>
1 parent 341fc10 commit 6f92d79

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// { dg-output "minus two!\r*\nelse\r*\n" }
2+
extern "C" {
3+
fn printf(s: *const i8, ...);
4+
}
5+
6+
fn foo(x: i32) {
7+
match x {
8+
-2 => {
9+
let a = "minus two!\n\0";
10+
let b = a as *const str;
11+
let c = b as *const i8;
12+
unsafe {
13+
printf(c);
14+
}
15+
}
16+
_ => {
17+
let a = "else\n\0";
18+
let b = a as *const str;
19+
let c = b as *const i8;
20+
unsafe {
21+
printf(c);
22+
}
23+
}
24+
}
25+
}
26+
27+
fn main() -> i32 {
28+
foo(-2);
29+
foo(2);
30+
0
31+
}

0 commit comments

Comments
 (0)