diff options
author | Faisal Abbas <90.abbasfaisal@gmail.com> | 2022-07-19 17:39:56 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2022-08-25 12:40:24 +0100 |
commit | bb4dd8fbc857a78bb4bfb69f1bdfdcbd9b1b6cdb (patch) | |
tree | ba3e4ba637bba99e6543f29603e8baf93fe14205 | |
parent | 121c8dd00de81ec9c11d494d402e4761dbe4fe4d (diff) | |
download | gcc-bb4dd8fbc857a78bb4bfb69f1bdfdcbd9b1b6cdb.zip gcc-bb4dd8fbc857a78bb4bfb69f1bdfdcbd9b1b6cdb.tar.gz gcc-bb4dd8fbc857a78bb4bfb69f1bdfdcbd9b1b6cdb.tar.bz2 |
gccrs const folding port: continue porting potential_constant_expression_1()
Following functions are ported in this changeset:
- decl_constant_var_p
- undeduced_auto_decl
- require_deduced_type
Signed-off-by: Faisal Abbas <90.abbasfaisal@gmail.com>
-rw-r--r-- | gcc/rust/backend/rust-tree.cc | 46 | ||||
-rw-r--r-- | gcc/rust/backend/rust-tree.h | 6 |
2 files changed, 52 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-tree.cc b/gcc/rust/backend/rust-tree.cc index e1ab7f1..028d88f 100644 --- a/gcc/rust/backend/rust-tree.cc +++ b/gcc/rust/backend/rust-tree.cc @@ -3969,4 +3969,50 @@ retry: } } +// forked from gcc/cp/decl2.cc decl_constant_var_p + +/* Nonzero for a VAR_DECL whose value can be used in a constant expression. + + [expr.const] + + An integral constant-expression can only involve ... const + variables of integral or enumeration types initialized with + constant expressions ... + + C++0x also allows constexpr variables and temporaries initialized + with constant expressions. We handle the former here, but the latter + are just folded away in cxx_eval_constant_expression. + + The standard does not require that the expression be non-volatile. + G++ implements the proposed correction in DR 457. */ + +bool +decl_constant_var_p (tree decl) +{ + if (!decl_maybe_constant_var_p (decl)) + return false; + + return DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl); +} + +// forked from gcc/cp/decl.cc undeduced_auto_decl + +/* Returns true iff DECL is a variable or function declared with an auto type + that has not yet been deduced to a real type. */ + +bool +undeduced_auto_decl (tree decl) +{ + return false; +} + +// forked from gcc/cp/decl.cc require_deduced_type + +/* Complain if DECL has an undeduced return type. */ + +bool +require_deduced_type (tree decl, tsubst_flags_t complain) +{ + return true; +} } // namespace Rust diff --git a/gcc/rust/backend/rust-tree.h b/gcc/rust/backend/rust-tree.h index fc83dc2..624f936 100644 --- a/gcc/rust/backend/rust-tree.h +++ b/gcc/rust/backend/rust-tree.h @@ -2542,6 +2542,12 @@ extern void cxx_incomplete_type_inform (const_tree); extern tree strip_top_quals (tree); +extern bool undeduced_auto_decl (tree); + +extern bool require_deduced_type (tree, tsubst_flags_t = tf_warning_or_error); + +extern bool decl_constant_var_p (tree); + // forked from gcc/cp/cp-tree.h enum |