aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/compile
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2025-04-03 15:39:58 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2025-04-08 10:17:13 +0200
commitf7fc904335edd53f428d76cd85a7bf3f8b55b2fe (patch)
tree19b9869c79cc4b3bf84eda55c92c9a4ce60577bb /gcc/testsuite/rust/compile
parent0f37641978a2ef2b7a50d230a16637a3cfd46c2d (diff)
downloadgcc-f7fc904335edd53f428d76cd85a7bf3f8b55b2fe.zip
gcc-f7fc904335edd53f428d76cd85a7bf3f8b55b2fe.tar.gz
gcc-f7fc904335edd53f428d76cd85a7bf3f8b55b2fe.tar.bz2
gccrs: Fix ICE on raw reference
This patch adds support for raw references which enforce the pointer type away from a reference type. Fixes Rust-GCC#3667 gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::address_expression): allow optional type * backend/rust-compile-base.h: update prototype * backend/rust-compile-expr.cc (CompileExpr::visit): update borrow expr * backend/rust-compile-extern.h: remove unused debug * backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile): update usage * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): lower raw ref * hir/tree/rust-hir-expr.cc (BorrowExpr::BorrowExpr): add flag for raw ref * hir/tree/rust-hir-expr.h (class BorrowExpr): add new raw ref field * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): add handle for raw ref gcc/testsuite/ChangeLog: * rust/compile/issue-3667.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/testsuite/rust/compile')
-rw-r--r--gcc/testsuite/rust/compile/issue-3667.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/compile/issue-3667.rs b/gcc/testsuite/rust/compile/issue-3667.rs
new file mode 100644
index 0000000..e72069c
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3667.rs
@@ -0,0 +1,24 @@
+// { dg-options "-w" }
+#![feature(raw_ref_op)]
+
+const pq1: () = {
+ let mut x = 2;
+ &raw mut x;
+}; //~ mutable reference
+
+static B: () = {
+ let mut x = 2;
+ &raw mut x;
+}; //~ mutable reference
+
+static mut C: () = {
+ let mut x = 2;
+ &raw mut x;
+}; //~ mutable reference
+
+const fn foo() {
+ let mut x = 0;
+ let y = &raw mut x; //~ mutable reference
+}
+
+fn main() {}