]> granicus.if.org Git - clang/commitdiff
Fix PR5298 - -Wmissing-noreturn shouldn't warn if the function is already
authorChris Lattner <sabre@nondot.org>
Sun, 25 Oct 2009 22:43:07 +0000 (22:43 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 25 Oct 2009 22:43:07 +0000 (22:43 +0000)
declared noreturn.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85075 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/Sema/return-noreturn.c

index 11dbf042f258a2105b66e2dfe3e9a4784026e39e..70cab66d87c5dba30ba24eafed47b51db71e019a 100644 (file)
@@ -1150,6 +1150,7 @@ void Sema::CheckFallThroughForFunctionDef(Decl *D, Stmt *Body) {
   // 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 @@ void Sema::CheckFallThroughForFunctionDef(Decl *D, Stmt *Body) {
         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 @@ void Sema::CheckFallThroughForBlock(QualType BlockTy, Stmt *Body) {
     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())
index e2452f407f4fb4009af129b537288ea6129835ee..8868c9ee0aeb37f27633ac11f9b27c9f9495c037 100644 (file)
@@ -27,3 +27,11 @@ __attribute__((__noreturn__)) void* test3(int arg) {
 __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();
+}