From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id 59A853AA841F; Wed, 8 Jun 2022 11:55:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 59A853AA841F Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] Constant folder now returns error_mark_node instead of nullptr X-Act-Checkin: gcc X-Git-Author: Nirmal Patel X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: 0024bc2f028369b871a65ceb11b2fddfb0f9c3aa X-Git-Newrev: f742bead5f4eb94908f188b99a3b261de0be9ca2 Message-Id: <20220608115533.59A853AA841F@sourceware.org> Date: Wed, 8 Jun 2022 11:55:33 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Jun 2022 11:55:33 -0000 https://gcc.gnu.org/g:f742bead5f4eb94908f188b99a3b261de0be9ca2 commit f742bead5f4eb94908f188b99a3b261de0be9ca2 Author: Nirmal Patel Date: Sat Dec 11 14:05:06 2021 -0500 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 Diff: --- gcc/rust/typecheck/rust-hir-const-fold.cc | 2 -- gcc/rust/typecheck/rust-hir-const-fold.h | 9 +-------- gcc/rust/typecheck/rust-hir-type-check-enumitem.h | 3 +-- 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 6acedd19b0f..1545c1a6efd 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 c965e25017c..d1f71277754 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 e4dcaeb2326..4df7df6dd12 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 ca4842a1630..4596973c2c1 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,