================ @@ -3910,8 +3910,13 @@ StmtResult Sema::BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, FnRetType = FD->getReturnType(); if (FD->hasAttrs()) Attrs = &FD->getAttrs(); - if (FD->isNoReturn()) - Diag(ReturnLoc, diag::warn_noreturn_function_has_return_expr) << FD; + if (FD->isNoReturn()) { + const FunctionScopeInfo *Scope = getEnclosingFunction(); + if (Scope && Scope->isCoroutine()) + Diag(ReturnLoc, diag::warn_noreturn_coroutine) << FD; + else + Diag(ReturnLoc, diag::warn_noreturn_function_has_return_expr) << FD; + } ---------------- Sirraide wrote:
```suggestion if (FD->isNoReturn() && !getCurFunction()->isCoroutine()) Diag(ReturnLoc, diag::warn_noreturn_function_has_return_expr) << FD; ``` As is, this would have the effect of emitting a warning on every `return` statement; I don’t think that’s what we want given that the problem is not that we’re returning from a noreturn function, but rather that the function shouldn’t be noreturn to begin with, so I’d do something like this instead. (also, `getCurFunction()` should be slightly faster than `getEnclosingFunction()` here and is equivalent because we’ve already handled capturing function scopes) https://github.com/llvm/llvm-project/pull/127623 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits