diff options
Diffstat (limited to 'clang/lib/Sema/SemaCoroutine.cpp')
-rw-r--r-- | clang/lib/Sema/SemaCoroutine.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaCoroutine.cpp b/clang/lib/Sema/SemaCoroutine.cpp index 67c8b9b1a78..f05a94ebe0e 100644 --- a/clang/lib/Sema/SemaCoroutine.cpp +++ b/clang/lib/Sema/SemaCoroutine.cpp @@ -1316,6 +1316,10 @@ bool CoroutineStmtBuilder::makeGroDeclAndReturnStmt() { if (Res.isInvalid()) return false; + if (GroType == FnRetType) { + GroDecl->setNRVOVariable(true); + } + S.AddInitializerToDecl(GroDecl, Res.get(), /*DirectInit=*/false); @@ -1339,8 +1343,6 @@ bool CoroutineStmtBuilder::makeGroDeclAndReturnStmt() { noteMemberDeclaredHere(S, ReturnValue, Fn); return false; } - if (cast<clang::ReturnStmt>(ReturnStmt.get())->getNRVOCandidate() == GroDecl) - GroDecl->setNRVOVariable(true); this->ReturnStmt = ReturnStmt.get(); return true; |