From: Chandler Carruth Date: Thu, 18 Aug 2011 02:04:29 +0000 (+0000) Subject: Remove the last FIXMEs on -Wunused-comparison since it got moved to X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5440bfaff6aec058b60bc6da75bb4f13b7a76491;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137916 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 9c87a3f323..e17188757b 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -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); 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); diff --git a/test/Parser/switch-recovery.cpp b/test/Parser/switch-recovery.cpp index a1df4261db..84ac0c899e 100644 --- a/test/Parser/switch-recovery.cpp +++ b/test/Parser/switch-recovery.cpp @@ -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; } diff --git a/test/SemaCXX/warn-unused-comparison.cpp b/test/SemaCXX/warn-unused-comparison.cpp index f790c669ff..c193462e15 100644 --- a/test/SemaCXX/warn-unused-comparison.cpp +++ b/test/SemaCXX/warn-unused-comparison.cpp @@ -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);