From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id 4B286385AC0A; Mon, 29 Aug 2022 15:33:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4B286385AC0A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1661787189; bh=+f67k+m1Bgr6GE+R8QYfrI3yRHUBPa5tOpePFyMK3OY=; h=From:To:Subject:Date:From; b=FxHYyppFjuYoZja2aRCTj/gllMTJ0HfEz3hCvipnH/GND80owVjsHt8Ce2nE6Lbf1 6M/qd01q5I3CS8z6usVqyCiKuQPpUS6Yb5Tvs/DwDq2zOwfpGS7/7EoYGDOiQh+qBe RUS/Q0Ydj7SjHlsjg/9geaAsmJhiJdaor1l8gxPo= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] gccrs const folding port: continue porting potential_constant_expression_1() X-Act-Checkin: gcc X-Git-Author: Faisal Abbas <90.abbasfaisal@gmail.com> X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: 121c8dd00de81ec9c11d494d402e4761dbe4fe4d X-Git-Newrev: bb4dd8fbc857a78bb4bfb69f1bdfdcbd9b1b6cdb Message-Id: <20220829153309.4B286385AC0A@sourceware.org> Date: Mon, 29 Aug 2022 15:33:09 +0000 (GMT) List-Id: 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