8sa1-gcc/gcc/testsuite/g++.dg/cpp2a/lambda-uneval10.C
Jason Merrill 03bed1538f PR c++/89241 - ICE with lambda in template parameter list.
We were getting confused by a lambda in template definition context that
isn't actually in the scope of any templated entity.  Fixed by telling
type_dependent_expression_p that such a lambda is type-dependent even if we
can't tell that from its closure type.  I've also restored the error for
defining a non-lambda class in a default template argument, and for a lambda
befor C++20.

	* parser.c (cp_parser_lambda_expression): Also reject a lambda in a
	template parameter list before C++20.
	* pt.c (type_dependent_expression_p): True for LAMBDA_EXPR.
	* semantics.c (begin_class_definition): Restore error about defining
	non-lambda class in template parm list.

From-SVN: r269972
2019-03-27 14:39:20 -04:00

13 lines
211 B
C

// PR c++/89421
template <int I = []{return 1;}()> // { dg-message "lambda" "" { target c++17_down } }
struct B
{
static const int i = I;
};
#if __cplusplus > 201703L
B<> b;
static_assert (b.i == 1);
#endif