diff options
author | Nirmal Patel <npate012@gmail.com> | 2021-12-11 14:05:06 -0500 |
---|---|---|
committer | Nirmal Patel <npate012@gmail.com> | 2021-12-11 14:05:06 -0500 |
commit | f742bead5f4eb94908f188b99a3b261de0be9ca2 (patch) | |
tree | 5adb6f371e41da32650cb8064c2b1d9e169b292a /gcc | |
parent | 0024bc2f028369b871a65ceb11b2fddfb0f9c3aa (diff) | |
download | gcc-f742bead5f4eb94908f188b99a3b261de0be9ca2.zip gcc-f742bead5f4eb94908f188b99a3b261de0be9ca2.tar.gz gcc-f742bead5f4eb94908f188b99a3b261de0be9ca2.tar.bz2 |
Constant folder now returns error_mark_node instead of nullptr
Removed nullptr checking on results from constant folder because when the
result is already error_mark_node, we no longer need to check if the result
is nullptr.
Fixes #692
Signed-off-by: Nirmal Patel <npate012@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/typecheck/rust-hir-const-fold.cc | 2 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-hir-const-fold.h | 9 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-enumitem.h | 3 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check.cc | 2 |
4 files changed, 2 insertions, 14 deletions
diff --git a/gcc/rust/typecheck/rust-hir-const-fold.cc b/gcc/rust/typecheck/rust-hir-const-fold.cc index 6acedd1..1545c1a 100644 --- a/gcc/rust/typecheck/rust-hir-const-fold.cc +++ b/gcc/rust/typecheck/rust-hir-const-fold.cc @@ -64,8 +64,6 @@ void ConstFoldItem::visit (HIR::ConstantItem &item) { auto folded_expr = ConstFoldExpr::fold (item.get_expr ()); - if (folded_expr == nullptr) - return; folded = folded_expr; } diff --git a/gcc/rust/typecheck/rust-hir-const-fold.h b/gcc/rust/typecheck/rust-hir-const-fold.h index c965e25..d1f7127 100644 --- a/gcc/rust/typecheck/rust-hir-const-fold.h +++ b/gcc/rust/typecheck/rust-hir-const-fold.h @@ -299,7 +299,7 @@ public: if (folder.ctx->get_backend ()->is_error_expression (folder.folded)) { rust_error_at (expr->get_locus (), "non const value"); - return nullptr; + return folder.ctx->get_backend ()->error_expression (); } folder.ctx->insert_const (expr->get_mappings ().get_hirid (), @@ -423,12 +423,7 @@ public: void visit (HIR::ArithmeticOrLogicalExpr &expr) override { auto lhs = ConstFoldExpr::fold (expr.get_lhs ()); - if (lhs == nullptr) - return; - auto rhs = ConstFoldExpr::fold (expr.get_rhs ()); - if (rhs == nullptr) - return; auto op = expr.get_expr_type (); auto location = expr.get_locus (); @@ -441,8 +436,6 @@ public: void visit (HIR::NegationExpr &expr) override { auto negated_expr = ConstFoldExpr::fold (expr.get_expr ().get ()); - if (negated_expr == nullptr) - return; auto op = expr.get_expr_type (); auto location = expr.get_locus (); diff --git a/gcc/rust/typecheck/rust-hir-type-check-enumitem.h b/gcc/rust/typecheck/rust-hir-type-check-enumitem.h index e4dcaeb23..4df7df6 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-enumitem.h +++ b/gcc/rust/typecheck/rust-hir-type-check-enumitem.h @@ -74,8 +74,7 @@ public: auto backend = rust_get_backend (); auto folded_discriminant = ConstFold::ConstFoldExpr::fold (discriminant.get ()); - if (folded_discriminant == nullptr - || backend->is_error_expression (folded_discriminant)) + if (backend->is_error_expression (folded_discriminant)) return; size_t specified_discriminant; diff --git a/gcc/rust/typecheck/rust-hir-type-check.cc b/gcc/rust/typecheck/rust-hir-type-check.cc index ca4842a..4596973 100644 --- a/gcc/rust/typecheck/rust-hir-type-check.cc +++ b/gcc/rust/typecheck/rust-hir-type-check.cc @@ -151,8 +151,6 @@ TypeCheckType::visit (HIR::ArrayType &type) return; auto capacity = ConstFold::ConstFoldExpr::fold (type.get_size_expr ()); - if (capacity == nullptr) - return; TyTy::BaseType *base = TypeCheckType::Resolve (type.get_element_type ()); translated = new TyTy::ArrayType (type.get_mappings ().get_hirid (), capacity, |