From: 0xllx0 <[email protected]>

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 <[email protected]>
---
 gcc/testsuite/rust/compile/issue-4148.rs | 26 ++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 gcc/testsuite/rust/compile/issue-4148.rs

diff --git a/gcc/testsuite/rust/compile/issue-4148.rs 
b/gcc/testsuite/rust/compile/issue-4148.rs
new file mode 100644
index 00000000000..599d73955ac
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-4148.rs
@@ -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))
+}
-- 
2.50.1

Reply via email to