diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -7229,16 +7229,7 @@ Builder.ReturnValue = Res.get(); if (S->hasDependentPromiseType()) { - // PR41909: We may find a generic coroutine lambda definition within a - // template function that is being instantiated. In this case, the lambda - // will have a dependent promise type, until it is used in an expression - // that creates an instantiation with a non-dependent promise type. We - // should not assert or build coroutine dependent statements for such a - // generic lambda. - auto *MD = dyn_cast_or_null(FD); - if (!MD || !MD->getParent()->isGenericLambda()) { - assert(!Promise->getType()->isDependentType() && - "the promise type must no longer be dependent"); + if (!Promise->getType()->isDependentType()) { assert(!S->getFallthroughHandler() && !S->getExceptionHandler() && !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() && "these nodes should not have been built yet"); diff --git a/clang/test/SemaCXX/coroutines.cpp b/clang/test/SemaCXX/coroutines.cpp --- a/clang/test/SemaCXX/coroutines.cpp +++ b/clang/test/SemaCXX/coroutines.cpp @@ -734,6 +734,26 @@ } template void ok_generic_lambda_coawait_PR41909(); // expected-note {{in instantiation of function template specialization 'ok_generic_lambda_coawait_PR41909' requested here}} +void ok_generic_lambda_coawait_PR41909_2() { + [](auto &arg) -> coro { // expected-warning {{expression result unused}} + co_await 12; + }; + [](auto &arg) -> coro { + co_await 24; + }("argument"); +} + +template +void ok_generic_lambda_coawait_PR41909_3() { + [](auto &arg) -> coro { // expected-warning {{expression result unused}} + []() -> coro { + co_await 12; + }; + co_await 24; + }; +} +template void ok_generic_lambda_coawait_PR41909_3(); // expected-note {{in instantiation of function template specialization 'ok_generic_lambda_coawait_PR41909_3' requested here}} + template<> struct std::experimental::coroutine_traits { using promise_type = promise; };