[cfe-commits] r139446 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/AnalysisBasedWarnings.cpp test/SemaObjC/return.m

Douglas Gregor dgregor at apple.com
Fri Sep 9 17:56:20 PDT 2011


Author: dgregor
Date: Fri Sep  9 19:56:20 2011
New Revision: 139446

URL: http://llvm.org/viewvc/llvm-project?rev=139446&view=rev
Log:
Fix a diagnostics crasher with -Wmissing-noreturn in Objective-C
methods, and improve the diagnostic slightly along the way. Fixes
<rdar://problem/10098695>.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
    cfe/trunk/test/SemaObjC/return.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=139446&r1=139445&r2=139446&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Sep  9 19:56:20 2011
@@ -236,7 +236,7 @@
 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'">,

Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=139446&r1=139445&r2=139446&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Fri Sep  9 19:56:20 2011
@@ -382,7 +382,10 @@
         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);
           }

Modified: cfe/trunk/test/SemaObjC/return.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/return.m?rev=139446&r1=139445&r2=139446&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/return.m (original)
+++ cfe/trunk/test/SemaObjC/return.m Fri Sep  9 19:56:20 2011
@@ -39,3 +39,12 @@
     }
 }
 
+void exit(int) __attribute__((noreturn));
+ at interface rdar10098695
+ at end
+
+ at implementation rdar10098695
+- (void)method { // expected-warning{{method 'method' could be declared with attribute 'noreturn'}}
+  exit(1);
+}
+ at end





More information about the cfe-commits mailing list