]> gcc.gnu.org Git - gcc.git/commitdiff
typecheck: add assert on resolve_root_path return value
authorMarc Poulhiès <dkm@kataplop.net>
Thu, 12 Aug 2021 09:51:26 +0000 (11:51 +0200)
committerMarc Poulhiès <dkm@kataplop.net>
Thu, 12 Aug 2021 20:39:25 +0000 (22:39 +0200)
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

index 6743c8b9f2de3fcac79bde07b14a92c9b48041a1..d88cb0b7f1d40fede5dedf15346a034f6209590d 100644 (file)
@@ -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)
This page took 0.063572 seconds and 5 git commands to generate.