[clang] Surface error for plain return statement in coroutine earlier (PR #100985)

Ilya Biryukov via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 29 02:21:37 PDT 2024


================
@@ -3747,6 +3747,16 @@ Sema::ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
         Diag(ReturnLoc, diag::err_acc_branch_in_out_compute_construct)
         << /*return*/ 1 << /*out of */ 0);
 
+  // using plain return in a coroutine is not allowed.
+  FunctionScopeInfo *FSI = getCurFunction();
+  if (getLangOpts().Coroutines && FSI->isCoroutine()) {
----------------
ilya-biryukov wrote:

Could we only do this when `FSI->FirstReturnLoc.isInvalid() == true` to make sure we do not start producing the error on every return statement?

Previously we only produced a single error, and this seems like a useful behavior to keep. Otherwise we're spamming people with error messages.

https://github.com/llvm/llvm-project/pull/100985


More information about the cfe-commits mailing list