Reimplement handling of lambdas in templates.
commit52e76545f1b5c4030498420d8a0c4d6439afb2b9
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 29 Aug 2017 20:37:15 +0000 (29 20:37 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 29 Aug 2017 20:37:15 +0000 (29 20:37 +0000)
treeb1c3f161803fc2b6d6b610a8db75bddd8b2369d1
parent6482ee1c8d9166d1918dfe23dd717bd8400055fc
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@251433 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/cp/ChangeLog
gcc/cp/class.c
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/init.c
gcc/cp/lambda.c
gcc/cp/parser.c
gcc/cp/pt.c
gcc/cp/semantics.c
gcc/testsuite/g++.dg/cpp1z/fold-lambda.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/Wshadow-6.C