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]>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.


Commit on github: 
https://github.com/Rust-GCC/gccrs/commit/6f92d797c5991cadbd2de5992cfa69740fb5abac

The commit has been mentioned in the following pull-request(s):
 - https://github.com/Rust-GCC/gccrs/pull/4369

 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 000000000..acfa4d2eb
--- /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
+}

base-commit: 341fc108d9402cd8b63479aa9d85b5fafb49803f
-- 
2.52.0

Reply via email to