aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/name-lookup.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/name-lookup.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/name-lookup.cc')
-rw-r--r--gcc/cp/name-lookup.cc2
1 files changed, 0 insertions, 2 deletions
diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc
index 25657cf..14e937d 100644
--- a/gcc/cp/name-lookup.cc
+++ b/gcc/cp/name-lookup.cc
@@ -4302,8 +4302,6 @@ begin_scope (scope_kind kind, tree entity)
case sk_function_parms:
scope->keep = keep_next_level_flag;
- if (entity)
- scope->immediate_fn_ctx_p = DECL_IMMEDIATE_FUNCTION_P (entity);
break;
case sk_namespace: