]> granicus.if.org Git - clang/commitdiff
Remove the last FIXMEs on -Wunused-comparison since it got moved to
authorChandler Carruth <chandlerc@gmail.com>
Thu, 18 Aug 2011 02:04:29 +0000 (02:04 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Thu, 18 Aug 2011 02:04:29 +0000 (02:04 +0000)
entirely use the existing -Wunused-value infrastructure. This also fixes
a few missed cases for -Wunused in general.

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

lib/Sema/SemaStmt.cpp
test/Parser/switch-recovery.cpp
test/SemaCXX/warn-unused-comparison.cpp

index 9c87a3f323b827e6c20ccf83b9f6d1c00088a3ff..e17188757b5b61825cf7cb78bc38d35b7cdbd126 100644 (file)
@@ -291,6 +291,8 @@ Sema::ActOnCaseStmt(SourceLocation CaseLoc, Expr *LHSVal,
 
 /// 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 @@ void Sema::ActOnCaseStmtBody(Stmt *caseStmt, Stmt *SubStmt) {
 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);
index a1df4261db454c504e3e25cbab2a49ee9a2290a8..84ac0c899e55ae6cb6e0d89e8e08b29ac8025b7c 100644 (file)
@@ -79,7 +79,7 @@ int test7(int i) {
     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;
   }
index f790c669ff5e60d29701b9fd79f8e5625e8f8c63..c193462e15c83c0a91b3e58f81a6d4fc1fa594fd 100644 (file)
@@ -44,18 +44,18 @@ void test() {
                // 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);