aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-08-12 20:59:44 +0000
committerGitHub <noreply@github.com>2021-08-12 20:59:44 +0000
commite53f1acb282a226cd037fd21e587c83f09c2e4af (patch)
tree06a07ec8baf70c99a64f98a339add56a3e31ff92 /gcc
parent3610c9b202b3197bd92ce7b8dbabcb86d4641ee6 (diff)
parent8208beaf1ecff0bf20db7575d671aa8fa61c2988 (diff)
downloadgcc-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.h5
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)