================
@@ -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;
+ }
----------------
Nerixyz wrote:
> It’s supposed to remove it iff the enclosing function is a coroutine.
Sorry, I missed the `!`.
> I still think it makes more sense to diagnose this when the FunctionDecl is
> created rather than when we try and return from it.
`CheckCompletedCoroutineBody` sounds like a good place to do that.
https://github.com/llvm/llvm-project/pull/127623
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits