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

commit r15-8159-gea32c9b17fa6485a0a53f12984a976650725a48e
Author: Pierre-Emmanuel Patry <pierre-emmanuel.pa...@embecosm.com>
Date:   Tue May 21 11:36:55 2024 +0200

    gccrs: Add some test for raw_ref_op to prevent regressions
    
    Add a test for the feature gate, as well as some test to ensure the raw
    keyword stays weak. Also add some tests to check whether the raw_ref_op
    syntax is parsed correctly.
    
    gcc/testsuite/ChangeLog:
    
            * rust/compile/not_raw_ref_op.rs: New test.
            * rust/compile/raw_ref_op.rs: New test.
            * rust/compile/raw_ref_op_feature_gate.rs: New test.
            * rust/compile/raw_ref_op_invalid.rs: New test.
    
    Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.pa...@embecosm.com>

Diff:
---
 gcc/testsuite/rust/compile/not_raw_ref_op.rs          |  9 +++++++++
 gcc/testsuite/rust/compile/raw_ref_op.rs              | 11 +++++++++++
 gcc/testsuite/rust/compile/raw_ref_op_feature_gate.rs |  8 ++++++++
 gcc/testsuite/rust/compile/raw_ref_op_invalid.rs      | 12 ++++++++++++
 4 files changed, 40 insertions(+)

diff --git a/gcc/testsuite/rust/compile/not_raw_ref_op.rs 
b/gcc/testsuite/rust/compile/not_raw_ref_op.rs
new file mode 100644
index 000000000000..f55f1846faba
--- /dev/null
+++ b/gcc/testsuite/rust/compile/not_raw_ref_op.rs
@@ -0,0 +1,9 @@
+// { dg-options "-frust-compile-until=lowering" }
+pub struct Toto {
+    u: usize,
+}
+
+pub fn test(raw: Toto) {
+    // Not raw ref op syntax, raw keyword is weak.
+    let _c = &raw;
+}
diff --git a/gcc/testsuite/rust/compile/raw_ref_op.rs 
b/gcc/testsuite/rust/compile/raw_ref_op.rs
new file mode 100644
index 000000000000..a97e58c62b0f
--- /dev/null
+++ b/gcc/testsuite/rust/compile/raw_ref_op.rs
@@ -0,0 +1,11 @@
+// { dg-options "-fsyntax-only" }
+#![feature(raw_ref_op)]
+
+pub struct Toto {
+    u: usize,
+}
+
+pub fn test(mut toto: Toto) {
+    let _a = &raw mut toto.u;
+    let _b = &raw const toto.u;
+}
diff --git a/gcc/testsuite/rust/compile/raw_ref_op_feature_gate.rs 
b/gcc/testsuite/rust/compile/raw_ref_op_feature_gate.rs
new file mode 100644
index 000000000000..256202b2da6a
--- /dev/null
+++ b/gcc/testsuite/rust/compile/raw_ref_op_feature_gate.rs
@@ -0,0 +1,8 @@
+// { dg-options "-frust-compile-until=lowering" }
+pub struct Toto {
+    u: usize,
+}
+
+pub fn test(mut toto: Toto) {
+    let _a = &raw mut toto.u; //{ dg-error "raw address of syntax is 
experimental." "" { target *-*-* }  }
+}
diff --git a/gcc/testsuite/rust/compile/raw_ref_op_invalid.rs 
b/gcc/testsuite/rust/compile/raw_ref_op_invalid.rs
new file mode 100644
index 000000000000..90e169f30f6b
--- /dev/null
+++ b/gcc/testsuite/rust/compile/raw_ref_op_invalid.rs
@@ -0,0 +1,12 @@
+// { dg-options "-fsyntax-only" }
+#![feature(raw_ref_op)]
+
+pub struct Toto {
+    u: usize,
+}
+
+pub fn test(mut toto: Toto) {
+    let _c = &raw toto.u; //{ dg-error "expecting .;. but .identifier. found" 
"" { target *-*-* }  }
+    //{ dg-excess-errors "Additional errors for parent items" { target *-*-* } 
}
+
+}

Reply via email to