public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] Constant folder now returns error_mark_node instead of nullptr Date: Wed, 8 Jun 2022 11:55:33 +0000 (GMT) [thread overview] Message-ID: <20220608115533.59A853AA841F@sourceware.org> (raw) https://gcc.gnu.org/g:f742bead5f4eb94908f188b99a3b261de0be9ca2 commit f742bead5f4eb94908f188b99a3b261de0be9ca2 Author: Nirmal Patel <npate012@gmail.com> 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 <npate012@gmail.com> 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,
reply other threads:[~2022-06-08 11:55 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220608115533.59A853AA841F@sourceware.org \ --to=tschwinge@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).