aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2024-05-21 11:36:55 +0200
committerP-E-P <32375388+P-E-P@users.noreply.github.com>2024-06-12 09:56:01 +0000
commit6fc8ad5340aa21110fe1655fef477aa5b94846f6 (patch)
treeeff3ee3c2de03a9940a3ecfe907e11687d8f4b88 /gcc
parentbd97356fbbbf889b049b25775b98dcace2d84885 (diff)
downloadgcc-6fc8ad5340aa21110fe1655fef477aa5b94846f6.zip
gcc-6fc8ad5340aa21110fe1655fef477aa5b94846f6.tar.gz
gcc-6fc8ad5340aa21110fe1655fef477aa5b94846f6.tar.bz2
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.patry@embecosm.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/rust/compile/not_raw_ref_op.rs9
-rw-r--r--gcc/testsuite/rust/compile/raw_ref_op.rs11
-rw-r--r--gcc/testsuite/rust/compile/raw_ref_op_feature_gate.rs8
-rw-r--r--gcc/testsuite/rust/compile/raw_ref_op_invalid.rs12
4 files changed, 40 insertions, 0 deletions
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 0000000..f55f184
--- /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 0000000..a97e58c
--- /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 0000000..256202b
--- /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 0000000..90e169f
--- /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 *-*-* } }
+
+}