aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/AnalysisBasedWarnings.cpp
diff options
context:
space:
mode:
authornerix <nerixdev@outlook.de>2025-02-18 22:30:39 +0100
committerGitHub <noreply@github.com>2025-02-18 22:30:39 +0100
commitdb5bc8e9d07729ce4994cc908275722a093e5c0c (patch)
tree506bb554c93087cf7e8f504abdd9bfd3b86a6325 /clang/lib/Sema/AnalysisBasedWarnings.cpp
parent8529bd7b964cc9fafe8fece84f7bd12dacb09560 (diff)
downloadllvm-db5bc8e9d07729ce4994cc908275722a093e5c0c.zip
llvm-db5bc8e9d07729ce4994cc908275722a093e5c0c.tar.gz
llvm-db5bc8e9d07729ce4994cc908275722a093e5c0c.tar.bz2
[Clang] Warn about `[[noreturn]]` on coroutines (#127623)
Declaring a coroutine `[[noreturn]]` doesn't make sense, because it will always return its handle. Clang previously crashed when trying to warn about this (diagnostic ID was 0). Fixes #127327.
Diffstat (limited to 'clang/lib/Sema/AnalysisBasedWarnings.cpp')
-rw-r--r--clang/lib/Sema/AnalysisBasedWarnings.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp b/clang/lib/Sema/AnalysisBasedWarnings.cpp
index 589869d..ce7d9be8 100644
--- a/clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -697,10 +697,12 @@ static void CheckFallThroughForBody(Sema &S, const Decl *D, const Stmt *Body,
return;
SourceLocation LBrace = Body->getBeginLoc(), RBrace = Body->getEndLoc();
auto EmitDiag = [&](SourceLocation Loc, unsigned DiagID) {
- if (IsCoroutine)
- S.Diag(Loc, DiagID) << FSI->CoroutinePromise->getType();
- else
+ if (IsCoroutine) {
+ if (DiagID != 0)
+ S.Diag(Loc, DiagID) << FSI->CoroutinePromise->getType();
+ } else {
S.Diag(Loc, DiagID);
+ }
};
// cpu_dispatch functions permit empty function bodies for ICC compatibility.