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] rust-constexpr.cc: add few more cases to eval_constant_expression() Date: Mon, 29 Aug 2022 15:34:35 +0000 (GMT) [thread overview] Message-ID: <20220829153435.8431F385AE5F@sourceware.org> (raw) https://gcc.gnu.org/g:6b440d46f16e3f93dd979852a1aab55f88add75f commit 6b440d46f16e3f93dd979852a1aab55f88add75f Author: Faisal Abbas <90.abbasfaisal@gmail.com> Date: Sat Aug 6 16:24:30 2022 +0100 rust-constexpr.cc: add few more cases to eval_constant_expression() Diff: --- gcc/rust/backend/rust-constexpr.cc | 60 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/gcc/rust/backend/rust-constexpr.cc b/gcc/rust/backend/rust-constexpr.cc index 14c2969dcba..6f645beba45 100644 --- a/gcc/rust/backend/rust-constexpr.cc +++ b/gcc/rust/backend/rust-constexpr.cc @@ -1730,6 +1730,31 @@ eval_constant_expression (const constexpr_ctx *ctx, tree t, bool lval, break; } + case COMPOUND_EXPR: { + /* check_return_expr sometimes wraps a TARGET_EXPR in a + COMPOUND_EXPR; don't get confused. Also handle EMPTY_CLASS_EXPR + introduced by build_call_a. */ + tree op0 = TREE_OPERAND (t, 0); + tree op1 = TREE_OPERAND (t, 1); + STRIP_NOPS (op1); + if ((TREE_CODE (op0) == TARGET_EXPR && op1 == TARGET_EXPR_SLOT (op0)) + || TREE_CODE (op1) == EMPTY_CLASS_EXPR) + r = eval_constant_expression (ctx, op0, lval, non_constant_p, + overflow_p, jump_target); + else + { + /* Check that the LHS is constant and then discard it. */ + eval_constant_expression (ctx, op0, true, non_constant_p, + overflow_p, jump_target); + if (*non_constant_p) + return t; + op1 = TREE_OPERAND (t, 1); + r = eval_constant_expression (ctx, op1, lval, non_constant_p, + overflow_p, jump_target); + } + } + break; + case REALPART_EXPR: case IMAGPART_EXPR: if (lval) @@ -1817,6 +1842,41 @@ eval_constant_expression (const constexpr_ctx *ctx, tree t, bool lval, overflow_p); break; + case TRY_CATCH_EXPR: + if (TREE_OPERAND (t, 0) == NULL_TREE) + { + r = void_node; + break; + } + r = eval_constant_expression (ctx, TREE_OPERAND (t, 0), lval, + non_constant_p, overflow_p, jump_target); + break; + + case CLEANUP_POINT_EXPR: { + auto_vec<tree, 2> cleanups; + vec<tree> *prev_cleanups = ctx->global->cleanups; + ctx->global->cleanups = &cleanups; + r = eval_constant_expression (ctx, TREE_OPERAND (t, 0), lval, + non_constant_p, overflow_p, jump_target); + ctx->global->cleanups = prev_cleanups; + unsigned int i; + tree cleanup; + /* Evaluate the cleanups. */ + FOR_EACH_VEC_ELT_REVERSE (cleanups, i, cleanup) + eval_constant_expression (ctx, cleanup, false, non_constant_p, + overflow_p); + } + break; + + case TRY_FINALLY_EXPR: + r = eval_constant_expression (ctx, TREE_OPERAND (t, 0), lval, + non_constant_p, overflow_p, jump_target); + if (!*non_constant_p) + /* Also evaluate the cleanup. */ + eval_constant_expression (ctx, TREE_OPERAND (t, 1), true, + non_constant_p, overflow_p); + break; + case CONSTRUCTOR: if (TREE_CONSTANT (t) && reduced_constant_expression_p (t)) {
reply other threads:[~2022-08-29 15:34 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=20220829153435.8431F385AE5F@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).