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] gccrs const folding port: continue porting potential_constant_expression_1() Date: Mon, 29 Aug 2022 15:33:09 +0000 (GMT) [thread overview] Message-ID: <20220829153309.4B286385AC0A@sourceware.org> (raw) https://gcc.gnu.org/g:bb4dd8fbc857a78bb4bfb69f1bdfdcbd9b1b6cdb commit bb4dd8fbc857a78bb4bfb69f1bdfdcbd9b1b6cdb Author: Faisal Abbas <90.abbasfaisal@gmail.com> Date: Tue Jul 19 17:39:56 2022 +0100 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> Diff: --- gcc/rust/backend/rust-tree.cc | 46 +++++++++++++++++++++++++++++++++++++++++++ gcc/rust/backend/rust-tree.h | 6 ++++++ 2 files changed, 52 insertions(+) diff --git a/gcc/rust/backend/rust-tree.cc b/gcc/rust/backend/rust-tree.cc index e1ab7f16074..028d88f420c 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 fc83dc2cb8f..624f9364bed 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
next reply other threads:[~2022-08-29 15:33 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-08-29 15:33 Thomas Schwinge [this message] -- strict thread matches above, loose matches on Subject: below -- 2022-08-29 15:33 Thomas Schwinge 2022-08-29 15:32 Thomas Schwinge 2022-08-29 15:32 Thomas Schwinge 2022-08-29 15:32 Thomas Schwinge 2022-08-29 15:32 Thomas Schwinge 2022-08-29 15:32 Thomas Schwinge 2022-08-29 15:32 Thomas Schwinge 2022-08-29 15:32 Thomas Schwinge 2022-06-30 18:50 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=20220829153309.4B286385AC0A@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).