]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Fix ICE when we dont get a reference type
authorPhilip Herron <herron.philip@googlemail.com>
Fri, 21 Apr 2023 16:52:01 +0000 (17:52 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:34:13 +0000 (18:34 +0100)
gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit):
return so we dont hit undefined behaviour

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/typecheck/rust-hir-type-check-pattern.cc

index f793b61cd99cdc025b9d63185c09230518bc12e2..bde707682387ed0695183a4a217a8f4cb12a21a9 100644 (file)
@@ -362,8 +362,11 @@ void
 TypeCheckPattern::visit (HIR::ReferencePattern &pattern)
 {
   if (parent->get_kind () != TyTy::TypeKind::REF)
-    rust_error_at (pattern.get_locus (), "expected %s, found reference",
-                  parent->as_string ().c_str ());
+    {
+      rust_error_at (pattern.get_locus (), "expected %s, found reference",
+                    parent->as_string ().c_str ());
+      return;
+    }
 
   TyTy::ReferenceType *ref_ty_ty = static_cast<TyTy::ReferenceType *> (parent);
   TyTy::BaseType *infered_base