[gcc/devel/rust/master] gccrs const folding port: continue porting potential_constant_expression_1()
Thomas Schwinge
tschwinge@gcc.gnu.org
Mon Aug 29 15:33:09 GMT 2022
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
More information about the Gcc-cvs
mailing list