aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/constexpr.cc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2022-10-07 20:34:53 -0400
committerJason Merrill <jason@redhat.com>2022-10-12 11:38:05 -0400
commit9bf74082bc93226e1ceb66430706e957e460c841 (patch)
tree43df246d62d87945fb10948b4cdab83734adfe55 /gcc/cp/constexpr.cc
parentbfcd9f84531fa99e9d00efd8bcfd3c8ac16fa360 (diff)
downloadgcc-9bf74082bc93226e1ceb66430706e957e460c841.zip
gcc-9bf74082bc93226e1ceb66430706e957e460c841.tar.gz
gcc-9bf74082bc93226e1ceb66430706e957e460c841.tar.bz2
c++: defer all consteval in default args [DR2631]
The proposed resolution of CWG2631 extends our current handling of source_location::current to all consteval functions: default arguments are not evaluated until they're used in a call, the same should apply to evaluation of immediate invocations. And similarly for default member initializers. Previously we folded source_location::current in cp_fold_r; now we fold all consteval calls in default arguments/member initializers in bot_replace. DR 2631 gcc/cp/ChangeLog: * cp-tree.h (source_location_current_p): Remove. * name-lookup.h (struct cp_binding_level): Remove immediate_fn_ctx_p. * call.cc (in_immediate_context): All default args and DMI are potentially immediate context. (immediate_invocation_p): Don't treat source_location specially. (struct in_consteval_if_p_temp_override): Move to cp-tree.h. * constexpr.cc (get_nth_callarg): Move to cp-tree.h. * cp-gimplify.cc (cp_fold_r): Don't fold consteval. * name-lookup.cc (begin_scope): Don't set immediate_fn_ctx_p. * parser.cc (cp_parser_lambda_declarator_opt): Likewise. (cp_parser_direct_declarator): Likewise. * pt.cc (tsubst_default_argument): Open sk_function_parms level. * tree.cc (source_location_current_p): Remove. (bot_replace): Fold consteval here. (break_out_target_exprs): Handle errors. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/consteval-defarg3.C: New test.
Diffstat (limited to 'gcc/cp/constexpr.cc')
-rw-r--r--gcc/cp/constexpr.cc20
1 files changed, 0 insertions, 20 deletions
diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index 06dcd71..2038f43 100644
--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -1324,26 +1324,6 @@ save_fundef_copy (tree fun, tree copy)
*slot = copy;
}
-/* We have an expression tree T that represents a call, either CALL_EXPR
- or AGGR_INIT_EXPR. Return the Nth argument. */
-
-static inline tree
-get_nth_callarg (tree t, int n)
-{
- switch (TREE_CODE (t))
- {
- case CALL_EXPR:
- return CALL_EXPR_ARG (t, n);
-
- case AGGR_INIT_EXPR:
- return AGGR_INIT_EXPR_ARG (t, n);
-
- default:
- gcc_unreachable ();
- return NULL;
- }
-}
-
/* Whether our evaluation wants a prvalue (e.g. CONSTRUCTOR or _CST),
a glvalue (e.g. VAR_DECL or _REF), or nothing. */