================
@@ -1120,7 +1120,7 @@ void Sema::CheckCompletedCoroutineBody(FunctionDecl *FD, 
Stmt *&Body) {
 
   // [stmt.return.coroutine]p1:
   //   A coroutine shall not enclose a return statement ([stmt.return]).
-  if (Fn->FirstReturnLoc.isValid()) {
+  if (Fn->FirstReturnLoc.isValid() && Fn->FirstReturnLoc < 
Fn->FirstCoroutineStmtLoc) {
----------------
ilya-biryukov wrote:

We now have some asymmetry between the way we handle errors for `co_await` 
after `return` and for `return` after `co_await`. (Also for other coroutine 
keywords, but I'll keep only mentioning `co_await` for simplicity).

I think we could get rid of that by moving this code into the function that 
handles `co_await`. It can check `FirstReturnLoc.isValid()` and issue and error 
in the same way as `return` checks for `FirstCoroutineStmtLoc.isValid()` (which 
is the implementation of `Fn->isCoroutine()`) and issues an error.

https://github.com/llvm/llvm-project/pull/100985
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to