// which this code would then warn about.
if (getDiagnostics().hasErrorOccurred())
return;
+
bool ReturnsVoid = false;
bool HasNoReturn = false;
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
Diag(Compound->getRBracLoc(), diag::warn_falloff_nonvoid_function);
break;
case NeverFallThrough:
- if (ReturnsVoid)
+ if (ReturnsVoid && !HasNoReturn)
Diag(Compound->getLBracLoc(), diag::warn_suggest_noreturn_function);
break;
}
return;
bool ReturnsVoid = false;
bool HasNoReturn = false;
- if (const FunctionType *FT = BlockTy->getPointeeType()->getAs<FunctionType>()) {
+ if (const FunctionType *FT =BlockTy->getPointeeType()->getAs<FunctionType>()){
if (FT->getResultType()->isVoidType())
ReturnsVoid = true;
if (FT->getNoReturnAttr())
__attribute__((__noreturn__)) void* test3_positive(int arg) {
while (0) foo_test_3();
} // expected-warning{{function declared 'noreturn' should not return}}
+
+
+// PR5298 - -Wmissing-noreturn shouldn't warn if the function is already
+// declared noreturn.
+void __attribute__((noreturn))
+test4() {
+ test2_positive();
+}