diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-08-12 20:59:44 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-12 20:59:44 +0000 |
commit | e53f1acb282a226cd037fd21e587c83f09c2e4af (patch) | |
tree | 06a07ec8baf70c99a64f98a339add56a3e31ff92 /gcc | |
parent | 3610c9b202b3197bd92ce7b8dbabcb86d4641ee6 (diff) | |
parent | 8208beaf1ecff0bf20db7575d671aa8fa61c2988 (diff) | |
download | gcc-e53f1acb282a226cd037fd21e587c83f09c2e4af.zip gcc-e53f1acb282a226cd037fd21e587c83f09c2e4af.tar.gz gcc-e53f1acb282a226cd037fd21e587c83f09c2e4af.tar.bz2 |
Merge #628
628: typecheck: add assert on resolve_root_path return value r=philberty a=dkm
resolve_root_path can return nullptr in case of error.
Better raise an error than dereference the pointer.
Co-authored-by: Marc Poulhiès <dkm@kataplop.net>
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) |