Implement P0315R4, Lambdas in unevaluated contexts.
commit9c093b14dba3e9556d53494a4de070715a449725
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 13 Nov 2018 04:49:09 +0000 (13 04:49 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 13 Nov 2018 04:49:09 +0000 (13 04:49 +0000)
treeccbb8ff54004ee0dd964a8e4e5621030bf011aa9
parentd1b312482df7b860b593d9d16b0d648f52bea71e
Implement P0315R4, Lambdas in unevaluated contexts.

When lambdas were added in C++11 they were banned from unevaluated contexts
as a way to avoid needing to deal with them in mangling or SFINAE.  This
proposal avoids that with a more narrow proposal: lambdas never compare as
equivalent (so we don't need to mangle them), and substitution failures
within a lambda are hard errors.  Lambdas appearing in places that types
couldn't previously have been declared introduces various complications; in
particular, it seems likely to mean types with no linkage being used more
broadly, risking ODR violations.  I want to follow up this patch with some
related diagnostics.

* decl2.c (min_vis_expr_r): Handle LAMBDA_EXPR.
* mangle.c (write_expression): Handle LAMBDA_EXPR.
* parser.c (cp_parser_lambda_expression): Allow lambdas in
unevaluated context.  Start the tentative firewall sooner.
(cp_parser_lambda_body): Use cp_evaluated.
* pt.c (iterative_hash_template_arg): Handle LAMBDA_EXPR.
(tsubst_function_decl): Substitute a lambda even if it isn't
dependent.
(tsubst_lambda_expr): Use cp_evaluated.  Always complain.
(tsubst_copy_and_build) [LAMBDA_EXPR]: Do nothing if tf_partial.
* semantics.c (begin_class_definition): Allow in template parm list.
* tree.c (strip_typedefs_expr): Pass through LAMBDA_EXPR.
(cp_tree_equal): Handle LAMBDA_EXPR.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@266056 138bc75d-0d04-0410-961f-82ee72b054a4
22 files changed:
gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/cp/mangle.c
gcc/cp/parser.c
gcc/cp/pt.c
gcc/cp/semantics.c
gcc/cp/tree.c
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice6.C
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-sfinae1.C
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-uneval.C
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-uneval2.C
gcc/testsuite/g++.dg/cpp2a/lambda-uneval1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/lambda-uneval2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/lambda-uneval3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/lambda-uneval4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/lambda-uneval5.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/lambda-uneval6.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/lambda-uneval7.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/lambda-uneval8.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/lambda-uneval9.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/lambda-uneval9.cc [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/lambda-uneval9.h [new file with mode: 0644]