diff options
author | Faisal Abbas <90.abbasfaisal@gmail.com> | 2022-08-06 21:32:41 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2022-08-25 12:40:27 +0100 |
commit | a38ad0b614ff5d601e5425824ad760235710eee5 (patch) | |
tree | b45a6c00458d63f25b90d782d1ddd0df7a2ea77b /gcc | |
parent | d780f02a54ff9cb0b5fd181eb21ae9afe2fd7d1c (diff) | |
download | gcc-a38ad0b614ff5d601e5425824ad760235710eee5.zip gcc-a38ad0b614ff5d601e5425824ad760235710eee5.tar.gz gcc-a38ad0b614ff5d601e5425824ad760235710eee5.tar.bz2 |
rust-constexpr.cc: port over more cases to eval_constant_expression
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/backend/rust-constexpr.cc | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-constexpr.cc b/gcc/rust/backend/rust-constexpr.cc index 276bfe9..340960e 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; |