public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Constant folder now returns error_mark_node instead of nullptr
@ 2022-06-08 11:55 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 11:55 UTC (permalink / raw)
To: gcc-cvs
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,
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-08 11:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 11:55 [gcc/devel/rust/master] Constant folder now returns error_mark_node instead of nullptr Thomas Schwinge
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).