[cfe-commits] r137916 - in /cfe/trunk: lib/Sema/SemaStmt.cpp test/Parser/switch-recovery.cpp test/SemaCXX/warn-unused-comparison.cpp

Chandler Carruth chandlerc at gmail.com
Wed Aug 17 19:04:29 PDT 2011


Author: chandlerc
Date: Wed Aug 17 21:04:29 2011
New Revision: 137916

URL: http://llvm.org/viewvc/llvm-project?rev=137916&view=rev
Log:
Remove the last FIXMEs on -Wunused-comparison since it got moved to
entirely use the existing -Wunused-value infrastructure. This also fixes
a few missed cases for -Wunused in general.

Modified:
    cfe/trunk/lib/Sema/SemaStmt.cpp
    cfe/trunk/test/Parser/switch-recovery.cpp
    cfe/trunk/test/SemaCXX/warn-unused-comparison.cpp

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=137916&r1=137915&r2=137916&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Wed Aug 17 21:04:29 2011
@@ -291,6 +291,8 @@
 
 /// ActOnCaseStmtBody - This installs a statement as the body of a case.
 void Sema::ActOnCaseStmtBody(Stmt *caseStmt, Stmt *SubStmt) {
+  DiagnoseUnusedExprResult(SubStmt);
+
   CaseStmt *CS = static_cast<CaseStmt*>(caseStmt);
   CS->setSubStmt(SubStmt);
 }
@@ -298,6 +300,8 @@
 StmtResult
 Sema::ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc,
                        Stmt *SubStmt, Scope *CurScope) {
+  DiagnoseUnusedExprResult(SubStmt);
+
   if (getCurFunction()->SwitchStack.empty()) {
     Diag(DefaultLoc, diag::err_default_not_in_switch);
     return Owned(SubStmt);

Modified: cfe/trunk/test/Parser/switch-recovery.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/switch-recovery.cpp?rev=137916&r1=137915&r2=137916&view=diff
==============================================================================
--- cfe/trunk/test/Parser/switch-recovery.cpp (original)
+++ cfe/trunk/test/Parser/switch-recovery.cpp Wed Aug 17 21:04:29 2011
@@ -79,7 +79,7 @@
     case false ? 1 : 2:
     true ? 1 : 2:  // expected-error {{expected 'case' keyword before expression}}
     case 10:
-      14 ? 3 : 4;
+      14 ? 3 : 4;  // expected-warning {{expression result unused}}
     default:
       return 1;
   }

Modified: cfe/trunk/test/SemaCXX/warn-unused-comparison.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unused-comparison.cpp?rev=137916&r1=137915&r2=137916&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-unused-comparison.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unused-comparison.cpp Wed Aug 17 21:04:29 2011
@@ -44,18 +44,18 @@
                // expected-note {{use '=' to turn this equality comparison into an assignment}}
     x == 7; // expected-warning {{equality comparison result unused}} \
             // expected-note {{use '=' to turn this equality comparison into an assignment}}
-  switch (42) default: x == 7; // FIXME: missing-warning {{equality comparison result unused}} \
-                               // FIXME: missing-note {{use '=' to turn this equality comparison into an assignment}}
-  switch (42) case 42: x == 7; // FIXME: missing-warning {{equality comparison result unused}} \
-                               // FIXME: missing-note {{use '=' to turn this equality comparison into an assignment}}
+  switch (42) default: x == 7; // expected-warning {{equality comparison result unused}} \
+                               // expected-note {{use '=' to turn this equality comparison into an assignment}}
+  switch (42) case 42: x == 7; // expected-warning {{equality comparison result unused}} \
+                               // expected-note {{use '=' to turn this equality comparison into an assignment}}
   switch (42) {
     case 1:
     case 2:
     default:
     case 3:
     case 4:
-      x == 7; // FIXME: missing-warning {{equality comparison result unused}} \
-              // FIXME: missing-note {{use '=' to turn this equality comparison into an assignment}}
+      x == 7; // expected-warning {{equality comparison result unused}} \
+              // expected-note {{use '=' to turn this equality comparison into an assignment}}
   }
 
   (void)(x == 7);





More information about the cfe-commits mailing list