8sa1-gcc/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice6.C
Jason Merrill 0c1e0d63fe 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
2018-11-12 23:49:09 -05:00

5 lines
115 B
C

// PR c++/51464
// { dg-do compile { target c++11 } }
template<int = sizeof([])> struct A {}; // { dg-error "" }