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: port over more cases to eval_constant_expression Date: Mon, 29 Aug 2022 15:34:45 +0000 (GMT) [thread overview] Message-ID: <20220829153445.A8E573856961@sourceware.org> (raw) https://gcc.gnu.org/g:a38ad0b614ff5d601e5425824ad760235710eee5 commit a38ad0b614ff5d601e5425824ad760235710eee5 Author: Faisal Abbas <90.abbasfaisal@gmail.com> Date: Sat Aug 6 21:32:41 2022 +0100 rust-constexpr.cc: port over more cases to eval_constant_expression Diff: --- gcc/rust/backend/rust-constexpr.cc | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/gcc/rust/backend/rust-constexpr.cc b/gcc/rust/backend/rust-constexpr.cc index 276bfe94e6f..340960e0ab6 100644 --- a/gcc/rust/backend/rust-constexpr.cc +++ b/gcc/rust/backend/rust-constexpr.cc @@ -1398,6 +1398,32 @@ eval_bare_aggregate (const constexpr_ctx *ctx, tree t, bool lval, return t; } +/* Subroutine of cxx_eval_constant_expression. + Like cxx_eval_unary_expression, except for trinary expressions. */ + +static tree +cxx_eval_trinary_expression (const constexpr_ctx *ctx, tree t, bool lval, + bool *non_constant_p, bool *overflow_p) +{ + int i; + tree args[3]; + tree val; + + for (i = 0; i < 3; i++) + { + args[i] = eval_constant_expression (ctx, TREE_OPERAND (t, i), lval, + non_constant_p, overflow_p); + VERIFY_CONSTANT (args[i]); + } + + val = fold_ternary_loc (EXPR_LOCATION (t), TREE_CODE (t), TREE_TYPE (t), + args[0], args[1], args[2]); + if (val == NULL_TREE) + return t; + VERIFY_CONSTANT (val); + return val; +} + /* Return true if T is a valid constant initializer. If a CONSTRUCTOR initializes all the members, the CONSTRUCTOR_NO_CLEARING flag will be cleared. @@ -1649,6 +1675,11 @@ eval_constant_expression (const constexpr_ctx *ctx, tree t, bool lval, r = rs_eval_indirect_ref (ctx, t, lval, non_constant_p, overflow_p); break; + case VEC_PERM_EXPR: + r = cxx_eval_trinary_expression (ctx, t, lval, non_constant_p, + overflow_p); + break; + case PAREN_EXPR: gcc_assert (!REF_PARENTHESIZED_P (t)); /* A PAREN_EXPR resulting from __builtin_assoc_barrier has no effect in @@ -1680,6 +1711,21 @@ eval_constant_expression (const constexpr_ctx *ctx, tree t, bool lval, return eval_constant_expression (ctx, BIND_EXPR_BODY (t), lval, non_constant_p, overflow_p, jump_target); + case OBJ_TYPE_REF: + /* Virtual function lookup. We don't need to do anything fancy. */ + return eval_constant_expression (ctx, OBJ_TYPE_REF_EXPR (t), lval, + non_constant_p, overflow_p); + + case EXIT_EXPR: { + tree cond = TREE_OPERAND (t, 0); + cond = eval_constant_expression (ctx, cond, /*lval*/ false, + non_constant_p, overflow_p); + VERIFY_CONSTANT (cond); + if (integer_nonzerop (cond)) + *jump_target = t; + } + break; + case RESULT_DECL: if (lval) return t;
next reply other threads:[~2022-08-29 15:34 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-08-29 15:34 Thomas Schwinge [this message] 2022-08-29 15:34 Thomas Schwinge
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=20220829153445.A8E573856961@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).