]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Add some test for raw_ref_op to prevent regressions
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Tue, 21 May 2024 09:36:55 +0000 (11:36 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Mon, 17 Mar 2025 15:35:34 +0000 (16:35 +0100)
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.patry@embecosm.com>
gcc/testsuite/rust/compile/not_raw_ref_op.rs [new file with mode: 0644]
gcc/testsuite/rust/compile/raw_ref_op.rs [new file with mode: 0644]
gcc/testsuite/rust/compile/raw_ref_op_feature_gate.rs [new file with mode: 0644]
gcc/testsuite/rust/compile/raw_ref_op_invalid.rs [new file with mode: 0644]

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 (file)
index 0000000..f55f184
--- /dev/null
@@ -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 (file)
index 0000000..a97e58c
--- /dev/null
@@ -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 (file)
index 0000000..256202b
--- /dev/null
@@ -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 (file)
index 0000000..90e169f
--- /dev/null
@@ -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 *-*-* } }
+
+}