https://github.com/zyn0217 created https://github.com/llvm/llvm-project/pull/80656
Poking the CI. >From 3ceeae611848b58f8d49c58295a625bdb052ac97 Mon Sep 17 00:00:00 2001 From: Younan Zhang <zyn7...@gmail.com> Date: Mon, 5 Feb 2024 18:01:34 +0800 Subject: [PATCH] GH78524 --- clang/lib/Parse/ParseExprCXX.cpp | 6 ++++- .../Parser/cxx-concepts-requires-clause.cpp | 27 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index fd262ff31e661..5c374d2eb452d 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -1385,6 +1385,11 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer( Diag(RAngleLoc, diag::err_lambda_template_parameter_list_empty); } else { + // We increase the template depth before recursing into a requires-clause. + // The abbreviated generic lambdas thereof could have different template + // depths, avoiding substituting into wrong template parameters during the + // satisfaction check. + ++CurTemplateDepthTracker; ExprResult RequiresClause; if (TryConsumeToken(tok::kw_requires)) { RequiresClause = @@ -1396,7 +1401,6 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer( Actions.ActOnLambdaExplicitTemplateParameterList( Intro, LAngleLoc, TemplateParams, RAngleLoc, RequiresClause); - ++CurTemplateDepthTracker; } } diff --git a/clang/test/Parser/cxx-concepts-requires-clause.cpp b/clang/test/Parser/cxx-concepts-requires-clause.cpp index 1ec1eefa12865..f268092728fdf 100644 --- a/clang/test/Parser/cxx-concepts-requires-clause.cpp +++ b/clang/test/Parser/cxx-concepts-requires-clause.cpp @@ -168,3 +168,30 @@ auto lambda4 = [] requires(sizeof(char) == 1){}; // expected-error {{expected bo #if __cplusplus <= 202002L // expected-warning@-2{{lambda without a parameter clause is a C++23 extension}} #endif + +namespace GH78524 { + +template <typename T> T Foo; + +template <typename T> auto C(Foo<T>); + +template <typename T> struct D { + decltype(T()(C<T>)) Type; +}; + +template <typename T, typename U> D<T> G(T, U) { return {}; } + +struct E {}; + +void F() { + G([]<typename T> +// ~~~~~~~~~~ T: 0,0 + requires requires { [](auto...) {}; }(T) +// ~~~~ auto: 1,0 + { return T(); }, + E{}); +} + +int a = []<int=0> requires requires { [](auto){}; } { return 0; }(); + +} // namespace GH78524 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits