aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-11-15 13:53:23 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-30 12:36:42 +0100
commit08999fb0354ee94e5902fd43bd8c43d9b9b3c74a (patch)
tree4cccdb2e8a38030ec67c57c56ddb6bb6287e9948
parent3e450ae1bb99d0111f6ca5f34ac8d6ea308c13d6 (diff)
downloadgcc-08999fb0354ee94e5902fd43bd8c43d9b9b3c74a.zip
gcc-08999fb0354ee94e5902fd43bd8c43d9b9b3c74a.tar.gz
gcc-08999fb0354ee94e5902fd43bd8c43d9b9b3c74a.tar.bz2
gccrs: Add new test for parsing errors on self pointers
Add new tests to highlight the behavior of errors thrown when meeting a self pointer. gcc/testsuite/ChangeLog: * rust/compile/self_const_ptr.rs: New test. * rust/compile/self_mut_ptr.rs: New test. * rust/compile/self_ptr.rs: New test. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
-rw-r--r--gcc/testsuite/rust/compile/self_const_ptr.rs8
-rw-r--r--gcc/testsuite/rust/compile/self_mut_ptr.rs8
-rw-r--r--gcc/testsuite/rust/compile/self_ptr.rs8
3 files changed, 24 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/compile/self_const_ptr.rs b/gcc/testsuite/rust/compile/self_const_ptr.rs
new file mode 100644
index 0000000..014fe1b
--- /dev/null
+++ b/gcc/testsuite/rust/compile/self_const_ptr.rs
@@ -0,0 +1,8 @@
+struct MyStruct;
+
+impl MyStruct {
+ pub fn do_something(*const self) {}
+ // { dg-error "cannot pass .self. by raw pointer" "" { target *-*-* } .-1 }
+ // { dg-error "failed to parse inherent impl item in inherent impl" "" { target *-*-* } .-2 }
+ // { dg-error "failed to parse item in crate" "" { target *-*-* } .-3 }
+}
diff --git a/gcc/testsuite/rust/compile/self_mut_ptr.rs b/gcc/testsuite/rust/compile/self_mut_ptr.rs
new file mode 100644
index 0000000..2a127b7
--- /dev/null
+++ b/gcc/testsuite/rust/compile/self_mut_ptr.rs
@@ -0,0 +1,8 @@
+struct MyStruct;
+
+impl MyStruct {
+ pub fn do_something(*mut self) {}
+ // { dg-error "cannot pass .self. by raw pointer" "" { target *-*-* } .-1 }
+ // { dg-error "failed to parse inherent impl item in inherent impl" "" { target *-*-* } .-2 }
+ // { dg-error "failed to parse item in crate" "" { target *-*-* } .-3 }
+}
diff --git a/gcc/testsuite/rust/compile/self_ptr.rs b/gcc/testsuite/rust/compile/self_ptr.rs
new file mode 100644
index 0000000..fd7ff6c
--- /dev/null
+++ b/gcc/testsuite/rust/compile/self_ptr.rs
@@ -0,0 +1,8 @@
+struct MyStruct;
+
+impl MyStruct {
+ pub fn do_something(*self) {}
+ // { dg-error "cannot pass .self. by raw pointer" "" { target *-*-* } .-1 }
+ // { dg-error "failed to parse inherent impl item in inherent impl" "" { target *-*-* } .-2 }
+ // { dg-error "failed to parse item in crate" "" { target *-*-* } .-3 }
+}