From: "lenny.chiadmi-delage" <[email protected]>
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]>
---
gcc/testsuite/rust/execute/issue-1245.rs | 31 ++++++++++++++++++++++++
1 file changed, 31 insertions(+)
create mode 100644 gcc/testsuite/rust/execute/issue-1245.rs
diff --git a/gcc/testsuite/rust/execute/issue-1245.rs
b/gcc/testsuite/rust/execute/issue-1245.rs
new file mode 100644
index 00000000000..acfa4d2ebfb
--- /dev/null
+++ b/gcc/testsuite/rust/execute/issue-1245.rs
@@ -0,0 +1,31 @@
+// { dg-output "minus two!\r*\nelse\r*\n" }
+extern "C" {
+ fn printf(s: *const i8, ...);
+}
+
+fn foo(x: i32) {
+ match x {
+ -2 => {
+ let a = "minus two!\n\0";
+ let b = a as *const str;
+ let c = b as *const i8;
+ unsafe {
+ printf(c);
+ }
+ }
+ _ => {
+ let a = "else\n\0";
+ let b = a as *const str;
+ let c = b as *const i8;
+ unsafe {
+ printf(c);
+ }
+ }
+ }
+}
+
+fn main() -> i32 {
+ foo(-2);
+ foo(2);
+ 0
+}
--
2.50.1