From 8208beaf1ecff0bf20db7575d671aa8fa61c2988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= Date: Thu, 12 Aug 2021 11:51:26 +0200 Subject: typecheck: add assert on resolve_root_path return value resolve_root_path can return nullptr in case of error. Better raise an error than dereference the pointer. --- gcc/rust/typecheck/rust-hir-type-check-expr.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc') diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.h b/gcc/rust/typecheck/rust-hir-type-check-expr.h index 6743c8b..d88cb0b 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-expr.h +++ b/gcc/rust/typecheck/rust-hir-type-check-expr.h @@ -21,6 +21,7 @@ #include "rust-hir-type-check-base.h" #include "rust-hir-full.h" +#include "rust-system.h" #include "rust-tyty.h" #include "rust-tyty-call.h" #include "rust-hir-type-check-struct-field.h" @@ -931,6 +932,9 @@ public: size_t offset = -1; TyTy::BaseType *tyseg = resolve_root_path (expr, &offset, &resolved_node_id); + + rust_assert (tyseg != nullptr); + if (tyseg->get_kind () == TyTy::TypeKind::ERROR) return; @@ -1202,6 +1206,7 @@ private: folded_array_capacity (nullptr), inside_loop (inside_loop) {} + // Beware: currently returns Tyty::ErrorType or nullptr in case of error. TyTy::BaseType *resolve_root_path (HIR::PathInExpression &expr, size_t *offset, NodeId *root_resolved_node_id) -- cgit v1.1