diff options
author | Jason Merrill <jason@redhat.com> | 2017-08-29 16:37:15 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2017-08-29 16:37:15 -0400 |
commit | f44a8dd56f5bfbd0596c39693e268ef880c06221 (patch) | |
tree | b1c3f161803fc2b6d6b610a8db75bddd8b2369d1 /gcc/cp/decl.c | |
parent | 72932ccf0ac4837b020d29b386d75fbceeb88735 (diff) | |
download | gcc-f44a8dd56f5bfbd0596c39693e268ef880c06221.zip gcc-f44a8dd56f5bfbd0596c39693e268ef880c06221.tar.gz gcc-f44a8dd56f5bfbd0596c39693e268ef880c06221.tar.bz2 |
Reimplement handling of lambdas in templates.
* cp-tree.h (LAMBDA_FUNCTION_P): Check DECL_DECLARES_FUNCTION_P.
* decl.c (start_preparsed_function): Call start_lambda_scope.
(finish_function): Call finish_lambda_scope.
* init.c (get_nsdmi): Call start/finish_lambda_scope.
* lambda.c (start_lambda_scope): Only ignore VAR_DECL in a function.
* parser.c (cp_parser_function_definition_after_declarator): Don't
call start/finish_lambda_scope.
* pt.c (retrieve_specialization): Ignore lambda functions in
templates.
(find_parameter_packs_r): Ignore capture proxies. Look into
lambdas.
(check_for_bare_parameter_packs): Allow bare packs in lambdas.
(tsubst_default_argument): Call start/finish_lambda_scope.
(tsubst_function_decl): Handle lambda functions differently.
(tsubst_template_decl): Likewise.
(tsubst_expr) [DECL_EXPR]: Skip closure declarations and capture
proxies.
(tsubst_lambda_expr): Create a new closure rather than instantiate
the one from the template.
(tsubst_copy_and_build): Don't register a specialization of a pack.
(regenerate_decl_from_template): Call start/finish_lambda_scope.
(instantiate_decl): Remove special lambda function handling.
* semantics.c (process_outer_var_ref): Remove special generic lambda
handling. Don't implicitly capture in a lambda in a template. Look
for an existing proxy.
* class.c (current_nonlambda_class_type): Use decl_type_context.
From-SVN: r251433
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r-- | gcc/cp/decl.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 23829b0..d6b80c6 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -15097,6 +15097,8 @@ start_preparsed_function (tree decl1, tree attrs, int flags) && !implicit_default_ctor_p (decl1)) cp_ubsan_maybe_initialize_vtbl_ptrs (current_class_ptr); + start_lambda_scope (decl1); + return true; } @@ -15462,6 +15464,8 @@ finish_function (int flags) if (fndecl == NULL_TREE) return error_mark_node; + finish_lambda_scope (); + if (c_dialect_objc ()) objc_finish_function (); @@ -15565,11 +15569,11 @@ finish_function (int flags) /* Lambda closure members are implicitly constexpr if possible. */ if (cxx_dialect >= cxx1z - && LAMBDA_TYPE_P (CP_DECL_CONTEXT (fndecl)) - && (processing_template_decl + && LAMBDA_TYPE_P (CP_DECL_CONTEXT (fndecl))) + DECL_DECLARED_CONSTEXPR_P (fndecl) + = ((processing_template_decl || is_valid_constexpr_fn (fndecl, /*complain*/false)) - && potential_constant_expression (DECL_SAVED_TREE (fndecl))) - DECL_DECLARED_CONSTEXPR_P (fndecl) = true; + && potential_constant_expression (DECL_SAVED_TREE (fndecl))); /* Save constexpr function body before it gets munged by the NRV transformation. */ |