P0595R1 - is_constant_evaluated
authorJakub Jelinek <jakub@redhat.com>
Wed, 8 Aug 2018 09:00:51 +0000 (11:00 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 8 Aug 2018 09:00:51 +0000 (11:00 +0200)
commite408261123697a82b5965c700fa2465999f0fd62
tree22ed906d9f15d60555219787db1ca461460a6741
parent5e539332c47faa6d6df728d27fae5d02805ca5ec
P0595R1 - is_constant_evaluated

P0595R1 - is_constant_evaluated
cp/
* cp-tree.h (enum cp_built_in_function): New.
(maybe_constant_init): Add pretend_const_required argument.
* typeck2.c (store_init_value): Pass true as new argument to
maybe_constant_init.
* constexpr.c (constexpr_fn_retval): Check also DECL_BUILT_IN_CLASS
for BUILT_IN_UNREACHABLE.
(struct constexpr_ctx): Add pretend_const_required field.
(cxx_eval_builtin_function_call): Use DECL_IS_BUILTIN_CONSTANT_P
macro.  Handle CP_BUILT_IN_IS_CONSTANT_EVALUATED.  Check also
DECL_BUILT_IN_CLASS for BUILT_IN_UNREACHABLE.
(cxx_eval_outermost_constant_expr): Add pretend_const_required
argument, initialize pretend_const_required field in ctx.  If the
result is TREE_CONSTANT and non_constant_p, retry with
pretend_const_required false if it was true.
(is_sub_constant_expr): Initialize pretend_const_required_field in
ctx.
(cxx_constant_value): Pass true as pretend_const_required to
cxx_eval_outermost_constant_expr.
(maybe_constant_value): Pass false as pretend_const_required to
cxx_eval_outermost_constant_expr.
(fold_non_dependent_expr): Likewise.
(maybe_constant_init_1): Add pretend_const_required argument, pass it
down to cxx_eval_outermost_constant_expr.  Pass !allow_non_constant
instead of false as strict to cxx_eval_outermost_constant_expr.
(maybe_constant_init): Add pretend_const_required argument, pass it
down to maybe_constant_init_1.
(cxx_constant_init): Pass true as pretend_const_required to
maybe_constant_init_1.
* cp-gimplify.c (cp_gimplify_expr): Handle CALL_EXPRs to
CP_BUILT_IN_IS_CONSTANT_EVALUATED.
(cp_fold): Don't fold CP_BUILT_IN_IS_CONSTANT_EVALUATED calls.
* decl.c: Include langhooks.h.
(cxx_init_decl_processing): Register __builtin_is_constant_evaluated
built-in.
* tree.c (builtin_valid_in_constant_expr_p): Return true for
CP_BUILT_IN_IS_CONSTANT_EVALUATED.
* pt.c (declare_integer_pack): Initialize DECL_FUNCTION_CODE.
testsuite/
* g++.dg/cpp2a/is-constant-evaluated1.C: New test.

From-SVN: r263392
gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/cp/cp-gimplify.c
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/pt.c
gcc/cp/tree.c
gcc/cp/typeck2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp2a/is-constant-evaluated1.C [new file with mode: 0644]