[cfe-commits] r85075 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Sema/return-noreturn.c
Chris Lattner
sabre at nondot.org
Sun Oct 25 15:43:07 PDT 2009
Author: lattner
Date: Sun Oct 25 17:43:07 2009
New Revision: 85075
URL: http://llvm.org/viewvc/llvm-project?rev=85075&view=rev
Log:
Fix PR5298 - -Wmissing-noreturn shouldn't warn if the function is already
declared noreturn.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/return-noreturn.c
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=85075&r1=85074&r2=85075&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sun Oct 25 17:43:07 2009
@@ -1150,6 +1150,7 @@
// which this code would then warn about.
if (getDiagnostics().hasErrorOccurred())
return;
+
bool ReturnsVoid = false;
bool HasNoReturn = false;
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
@@ -1192,7 +1193,7 @@
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;
}
@@ -1214,7 +1215,7 @@
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())
Modified: cfe/trunk/test/Sema/return-noreturn.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/return-noreturn.c?rev=85075&r1=85074&r2=85075&view=diff
==============================================================================
--- cfe/trunk/test/Sema/return-noreturn.c (original)
+++ cfe/trunk/test/Sema/return-noreturn.c Sun Oct 25 17:43:07 2009
@@ -27,3 +27,11 @@
__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();
+}
More information about the cfe-commits
mailing list