diff options
author | Marc Poulhiès <dkm@kataplop.net> | 2021-08-12 11:51:26 +0200 |
---|---|---|
committer | Marc Poulhiès <dkm@kataplop.net> | 2021-08-12 22:39:25 +0200 |
commit | 8208beaf1ecff0bf20db7575d671aa8fa61c2988 (patch) | |
tree | 06a07ec8baf70c99a64f98a339add56a3e31ff92 /gcc | |
parent | 3610c9b202b3197bd92ce7b8dbabcb86d4641ee6 (diff) | |
download | gcc-8208beaf1ecff0bf20db7575d671aa8fa61c2988.zip gcc-8208beaf1ecff0bf20db7575d671aa8fa61c2988.tar.gz gcc-8208beaf1ecff0bf20db7575d671aa8fa61c2988.tar.bz2 |
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.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-expr.h | 5 |
1 files changed, 5 insertions, 0 deletions
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) |