Skip to content

Commit afffa0d

Browse files
authored
[Clang] Do not emit -Wmissing-noreturn when [[noreturn]] is present (#148552)
Fix a false positve warning which was introduced by #146234.
1 parent 87e39c3 commit afffa0d

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1976,7 +1976,7 @@ void clang::inferNoReturnAttr(Sema &S, const Decl *D) {
19761976
Diags.isIgnored(diag::warn_suggest_noreturn_function, FD->getLocation()))
19771977
return;
19781978

1979-
if (!FD->hasAttr<NoReturnAttr>() && !FD->hasAttr<InferredNoReturnAttr>() &&
1979+
if (!FD->isNoReturn() && !FD->hasAttr<InferredNoReturnAttr>() &&
19801980
isKnownToAlwaysThrow(FD)) {
19811981
NonConstFD->addAttr(InferredNoReturnAttr::CreateImplicit(S.Context));
19821982

clang/test/SemaCXX/wmissing-noreturn-suggestion.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,25 @@ int ensureZero(int i) {
2121
if (i == 0) return 0;
2222
throwError("ERROR"); // no-warning
2323
}
24+
25+
26+
template <typename Ex>
27+
[[noreturn]]
28+
void tpl_throws(Ex const& e) {
29+
throw e;
30+
}
31+
32+
[[noreturn]]
33+
void tpl_throws_test() {
34+
tpl_throws(0);
35+
}
36+
37+
[[gnu::noreturn]]
38+
int gnu_throws() {
39+
throw 0;
40+
}
41+
42+
[[noreturn]]
43+
int cxx11_throws() {
44+
throw 0;
45+
}

0 commit comments

Comments
 (0)