[clang] [Clang] Warn about `[[noreturn]]` on coroutines (PR #127623)

via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 18 12:48:28 PST 2025


================
@@ -1176,6 +1176,10 @@ void Sema::CheckCompletedCoroutineBody(FunctionDecl *FD, Stmt *&Body) {
   for (AddrLabelExpr *ALE : Fn->AddrLabels)
     Diag(ALE->getBeginLoc(), diag::err_coro_invalid_addr_of_label);
 
+  // Coroutines always return a handle, so they can't be [[noreturn]].
+  if (Fn->isCoroutine())
+    Diag(FD->getLocation(), diag::warn_noreturn_coroutine) << FD;
----------------
Sirraide wrote:

```suggestion
  // Coroutines always return a handle, so they can't be [[noreturn]].
  Diag(FD->getLocation(), diag::warn_noreturn_coroutine) << FD;
```
I should really hope we don’t get here if this *isn’t* a coroutine. 👀

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


More information about the cfe-commits mailing list