]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: tests: added extra parens compile test
author0xllx0 <github+elle@weathered-steel.dev>
Tue, 30 Sep 2025 05:29:10 +0000 (05:29 +0000)
committerArthur Cohen <arthur.cohen@embecosm.com>
Thu, 30 Oct 2025 20:30:54 +0000 (21:30 +0100)
Adds a test to verify extra parentheses are discarded, and the source is
compiled as expected.

Resolves: Rust-GCC/gccrs#2886

gcc/testsuite/ChangeLog:

* rust/compile/issue-4148.rs: New test.

Signed-off-by: Elle Rhumsaa <elle@weathered-steel.dev>
gcc/testsuite/rust/compile/issue-4148.rs [new file with mode: 0644]

diff --git a/gcc/testsuite/rust/compile/issue-4148.rs b/gcc/testsuite/rust/compile/issue-4148.rs
new file mode 100644 (file)
index 0000000..599d739
--- /dev/null
@@ -0,0 +1,26 @@
+// { dg-excess-errors "warnings" }
+
+// TODO: all `xfail` conditions should be changed to `target` once the ICE in #4148 is resolved
+
+pub fn ret_parens(x: i32) -> i32 {
+    // { dg-warning "unnecessary parentheses around block return value" "#4148" { xfail *-*-* } .+1 }
+    ((x+1))
+}
+
+// { dg-warning "unnecessary parentheses around type" "#4148" { xfail *-*-* } .+1 }
+// { dg-warning "unnecessary parentheses around pattern" "#4148" { xfail *-*-* } .+1 }
+pub fn arg_ret_parens((x): (i32)) -> (i32) {
+    // { dg-warning "unnecessary parentheses around block return value" "#4148" { xfail *-*-* } .+1 }
+    ((x+1))
+}
+
+// { dg-warning "unnecessary parentheses around type" "#4148" { xfail *-*-* } .+1 }
+pub fn ret_rpit_parens2(x: i32) -> (i32) {
+    // { dg-warning "unnecessary parentheses around block return value" "#4148" { xfail *-*-* } .+1 }
+    ((x+1))
+}
+
+pub fn ret_parens3(x: i32) -> i32 {
+    // { dg-warning "unnecessary parentheses around block return value" "#4148" { xfail *-*-* } .+1 }
+    ((x+1))
+}