diff options
author | Faisal Abbas <90.abbasfaisal@gmail.com> | 2022-08-06 19:12:47 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2022-08-25 12:40:27 +0100 |
commit | d780f02a54ff9cb0b5fd181eb21ae9afe2fd7d1c (patch) | |
tree | c20bab0a1637b28de39e0a5e81e8064c58cecf6d /gcc/rust/backend/rust-tree.cc | |
parent | 6b440d46f16e3f93dd979852a1aab55f88add75f (diff) | |
download | gcc-d780f02a54ff9cb0b5fd181eb21ae9afe2fd7d1c.zip gcc-d780f02a54ff9cb0b5fd181eb21ae9afe2fd7d1c.tar.gz gcc-d780f02a54ff9cb0b5fd181eb21ae9afe2fd7d1c.tar.bz2 |
rust-constexpr.cc: port over cxx_eval_outermost_constant_expr
Diffstat (limited to 'gcc/rust/backend/rust-tree.cc')
-rw-r--r-- | gcc/rust/backend/rust-tree.cc | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-tree.cc b/gcc/rust/backend/rust-tree.cc index 289b4b9..ad457a2 100644 --- a/gcc/rust/backend/rust-tree.cc +++ b/gcc/rust/backend/rust-tree.cc @@ -4108,4 +4108,47 @@ is_empty_field (tree decl) return r; } +// forked from gcc/cp/call.cc in_immediate_context + +/* Return true if in an immediate function context, or an unevaluated operand, + or a subexpression of an immediate invocation. */ + +bool +in_immediate_context () +{ + return false; +} + +// forked from gcc/cp/cvt.cc cp_get_fndecl_from_callee + +/* FN is the callee of a CALL_EXPR or AGGR_INIT_EXPR; return the FUNCTION_DECL + if we can. */ + +tree +rs_get_fndecl_from_callee (tree fn, bool fold /* = true */) +{ + if (fn == NULL_TREE) + return fn; + if (TREE_CODE (fn) == FUNCTION_DECL) + return fn; + tree type = TREE_TYPE (fn); + if (type == NULL_TREE || !INDIRECT_TYPE_P (type)) + return NULL_TREE; + if (fold) + fn = Compile::maybe_constant_init (fn); + STRIP_NOPS (fn); + if (TREE_CODE (fn) == ADDR_EXPR || TREE_CODE (fn) == FDESC_EXPR) + fn = TREE_OPERAND (fn, 0); + if (TREE_CODE (fn) == FUNCTION_DECL) + return fn; + return NULL_TREE; +} + +// forked from gcc/cp/cvt.cc cp_get_callee_fndecl_nofold +tree +rs_get_callee_fndecl_nofold (tree call) +{ + return rs_get_fndecl_from_callee (cp_get_callee (call), false); +} + } // namespace Rust |