https://gcc.gnu.org/g:b3ac5216000e701a2d56f9d527a5e8366ebda622

commit r16-4879-gb3ac5216000e701a2d56f9d527a5e8366ebda622
Author: 0xllx0 <[email protected]>
Date:   Tue Sep 30 05:29:10 2025 +0000

    gccrs: tests: added extra parens compile test
    
    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]>

Diff:
---
 gcc/testsuite/rust/compile/issue-4148.rs | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/gcc/testsuite/rust/compile/issue-4148.rs 
b/gcc/testsuite/rust/compile/issue-4148.rs
new file mode 100644
index 000000000000..599d73955acf
--- /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))
+}

Reply via email to