[PATCH] D62550: [coroutines][PR41909] Don't build dependent coroutine statements for generic lambda
Brian Gesiak via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 2 17:47:05 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362348: [coroutines][PR41909] Don't build dependent coroutine statements for generic… (authored by modocache, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62550/new/
https://reviews.llvm.org/D62550
Files:
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/SemaCXX/coroutines.cpp
Index: cfe/trunk/test/SemaCXX/coroutines.cpp
===================================================================
--- cfe/trunk/test/SemaCXX/coroutines.cpp
+++ cfe/trunk/test/SemaCXX/coroutines.cpp
@@ -720,6 +720,16 @@
co_await 42;
}
+template<typename T> void ok_generic_lambda_coawait_PR41909() {
+ [](auto& arg) -> coro<good_promise_1> { // expected-warning {{expression result unused}}
+ co_await 12;
+ };
+ [](auto &arg) -> coro<good_promise_1> {
+ co_await 24;
+ }("argument");
+}
+template void ok_generic_lambda_coawait_PR41909<int>(); // expected-note {{in instantiation of function template specialization 'ok_generic_lambda_coawait_PR41909<int>' requested here}}
+
template<> struct std::experimental::coroutine_traits<int, int, const char**>
{ using promise_type = promise; };
Index: cfe/trunk/lib/Sema/TreeTransform.h
===================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h
+++ cfe/trunk/lib/Sema/TreeTransform.h
@@ -7163,13 +7163,22 @@
Builder.ReturnValue = Res.get();
if (S->hasDependentPromiseType()) {
- assert(!Promise->getType()->isDependentType() &&
- "the promise type must no longer be dependent");
- assert(!S->getFallthroughHandler() && !S->getExceptionHandler() &&
- !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() &&
- "these nodes should not have been built yet");
- if (!Builder.buildDependentStatements())
- return StmtError();
+ // 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<CXXMethodDecl>(FD);
+ if (!MD || !MD->getParent()->isGenericLambda()) {
+ assert(!Promise->getType()->isDependentType() &&
+ "the promise type must no longer be dependent");
+ assert(!S->getFallthroughHandler() && !S->getExceptionHandler() &&
+ !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() &&
+ "these nodes should not have been built yet");
+ if (!Builder.buildDependentStatements())
+ return StmtError();
+ }
} else {
if (auto *OnFallthrough = S->getFallthroughHandler()) {
StmtResult Res = getDerived().TransformStmt(OnFallthrough);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62550.202627.patch
Type: text/x-patch
Size: 2558 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190603/88e73ffa/attachment.bin>
More information about the llvm-commits
mailing list