diff options
author | Jason Merrill <jason@redhat.com> | 2018-11-12 23:49:09 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2018-11-12 23:49:09 -0500 |
commit | 0c1e0d63fe0ceabbd04384070f3b59f8bf50de09 (patch) | |
tree | ccbb8ff54004ee0dd964a8e4e5621030bf011aa9 /gcc/cp/mangle.c | |
parent | 7d119905abdf28f56486be0ca01a42f8efcea1a2 (diff) | |
download | gcc-0c1e0d63fe0ceabbd04384070f3b59f8bf50de09.zip gcc-0c1e0d63fe0ceabbd04384070f3b59f8bf50de09.tar.gz gcc-0c1e0d63fe0ceabbd04384070f3b59f8bf50de09.tar.bz2 |
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.
From-SVN: r266056
Diffstat (limited to 'gcc/cp/mangle.c')
-rw-r--r-- | gcc/cp/mangle.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index b9d8ee2..64415894 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -3139,6 +3139,16 @@ write_expression (tree expr) write_expression (val); write_char ('E'); } + else if (code == LAMBDA_EXPR) + { + /* [temp.over.link] Two lambda-expressions are never considered + equivalent. + + So just use the closure type mangling. */ + write_string ("tl"); + write_type (LAMBDA_EXPR_CLOSURE (expr)); + write_char ('E'); + } else if (dependent_name (expr)) { write_unqualified_id (dependent_name (expr)); |