P0595R1 - is_constant_evaluated
commit18d371d3b1d11d64f229a453e390c18493a5d661
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 8 Aug 2018 09:00:51 +0000 (8 09:00 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 8 Aug 2018 09:00:51 +0000 (8 09:00 +0000)
tree22ed906d9f15d60555219787db1ca461460a6741
parentbe6af76629ad020df24a189cf46ad6f88a1507b4
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@263392 138bc75d-0d04-0410-961f-82ee72b054a4
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]