]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Add test case showing RPIT working to close issue
authorPhilip Herron <herron.philip@googlemail.com>
Thu, 19 Jun 2025 18:37:10 +0000 (19:37 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 5 Aug 2025 14:36:49 +0000 (16:36 +0200)
Fixes Rust-GCC#1486

gcc/testsuite/ChangeLog:

* rust/execute/torture/issue-1481.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/testsuite/rust/execute/torture/issue-1481.rs [new file with mode: 0644]

diff --git a/gcc/testsuite/rust/execute/torture/issue-1481.rs b/gcc/testsuite/rust/execute/torture/issue-1481.rs
new file mode 100644 (file)
index 0000000..2ff78d9
--- /dev/null
@@ -0,0 +1,35 @@
+/* { dg-output "called Foo::print\\(\\)\r*" } */
+/* { dg-options "-w" } */
+
+#[lang = "sized"]
+trait Sized {}
+
+trait Printable {
+    fn print(&self);
+}
+
+struct Foo;
+
+impl Printable for Foo {
+    fn print(&self) {
+        // Simulate output
+        unsafe {
+            puts("called Foo::print()\0" as *const _ as *const i8);
+        }
+    }
+}
+
+fn get_printable() -> impl Printable {
+    Foo
+}
+
+extern "C" {
+    fn puts(s: *const i8);
+}
+
+fn main() -> i32 {
+    let p = get_printable();
+    p.print();
+
+    0
+}