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
13 lines
211 B
C
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
|