]> granicus.if.org Git - clang/commitdiff
Fix a diagnostics crasher with -Wmissing-noreturn in Objective-C
authorDouglas Gregor <dgregor@apple.com>
Sat, 10 Sep 2011 00:56:20 +0000 (00:56 +0000)
committerDouglas Gregor <dgregor@apple.com>
Sat, 10 Sep 2011 00:56:20 +0000 (00:56 +0000)
methods, and improve the diagnostic slightly along the way. Fixes
<rdar://problem/10098695>.

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

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/AnalysisBasedWarnings.cpp
test/SemaObjC/return.m

index bd18b2f63f1e48d3807770f53ca814c705bc7d12..58bfbcfd28ade2f0b3f967a3daa04ca22021dc4d 100644 (file)
@@ -236,7 +236,7 @@ def err_maybe_falloff_nonvoid_block : Error<
 def err_falloff_nonvoid_block : Error<
   "control reaches end of non-void block">;
 def warn_suggest_noreturn_function : Warning<
-  "function %0 could be declared with attribute 'noreturn'">,
+  "%select{function|method}0 %1 could be declared with attribute 'noreturn'">,
   InGroup<DiagGroup<"missing-noreturn">>, DefaultIgnore;
 def warn_suggest_noreturn_block : Warning<
   "block could be declared with attribute 'noreturn'">,
index 823cbf74f55a0cd531c45bdcbb44fa7106c15109..30b6b0c8e326eeed8f8fa55c56e1ce4ff1690485 100644 (file)
@@ -382,7 +382,10 @@ static void CheckFallThroughForBody(Sema &S, const Decl *D, const Stmt *Body,
         if (ReturnsVoid && !HasNoReturn && CD.diag_NeverFallThroughOrReturn) {
           if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
             S.Diag(Compound->getLBracLoc(), CD.diag_NeverFallThroughOrReturn)
-              << FD;
+              << 0 << FD;
+          } else if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) {
+            S.Diag(Compound->getLBracLoc(), CD.diag_NeverFallThroughOrReturn)
+              << 1 << MD;
           } else {
             S.Diag(Compound->getLBracLoc(), CD.diag_NeverFallThroughOrReturn);
           }
index 88e6e6381e60b76393e124598d1437819c0fea80..4e70bde1edc14894f31404cb405c3fbb9f91f5a1 100644 (file)
@@ -39,3 +39,12 @@ NSString *rdar_4289832() {  // no-warning
     }
 }
 
+void exit(int) __attribute__((noreturn));
+@interface rdar10098695
+@end
+
+@implementation rdar10098695
+- (void)method { // expected-warning{{method 'method' could be declared with attribute 'noreturn'}}
+  exit(1);
+}
+@end