summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2017-11-20 17:48:54 +0000
committerHans Wennborg <hans@hanshq.net>2017-11-20 17:48:54 +0000
commit59ad15093932e111dd0ec00a96161f5e0da83508 (patch)
treebbfff57c87b238885993cbd32c2e9774b2b2a22c
parent8e7018d92f90e8c906660deb549ee042ee05e632 (diff)
downloadbcm5719-llvm-59ad15093932e111dd0ec00a96161f5e0da83508.tar.gz
bcm5719-llvm-59ad15093932e111dd0ec00a96161f5e0da83508.zip
Revert r318456 "Issue -Wempty-body warnings for else blocks"
This caused warnings also when the if or else comes from macros. There was an attempt to fix this in r318556, but that introduced new problems and was reverted. Reverting this too until the whole issue is sorted. > This looks like it was just an oversight. > > Fixes http://llvm.org/pr35319 > > git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@318456 91177308-0d34-0410-b5e6-96231b3b80d8 llvm-svn: 318667
-rw-r--r--clang/include/clang/Basic/DiagnosticSemaKinds.td2
-rw-r--r--clang/lib/Sema/SemaStmt.cpp4
-rw-r--r--clang/test/SemaCXX/warn-empty-body.cpp20
3 files changed, 1 insertions, 25 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index def942c1e54..348b225f916 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8094,8 +8094,6 @@ def err_switch_incomplete_class_type : Error<
def warn_empty_if_body : Warning<
"if statement has empty body">, InGroup<EmptyBody>;
-def warn_empty_else_body : Warning<
- "else clause has empty body">, InGroup<EmptyBody>;
def warn_empty_for_body : Warning<
"for loop has empty body">, InGroup<EmptyBody>;
def warn_empty_range_based_for_body : Warning<
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 07b70305c19..3a3eb5e7b5e 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -527,9 +527,7 @@ Sema::ActOnIfStmt(SourceLocation IfLoc, bool IsConstexpr, Stmt *InitStmt,
CondExpr->getExprLoc()))
CommaVisitor(*this).Visit(CondExpr);
- if (elseStmt)
- DiagnoseEmptyStmtBody(ElseLoc, elseStmt, diag::warn_empty_else_body);
- else
+ if (!elseStmt)
DiagnoseEmptyStmtBody(CondExpr->getLocEnd(), thenStmt,
diag::warn_empty_if_body);
diff --git a/clang/test/SemaCXX/warn-empty-body.cpp b/clang/test/SemaCXX/warn-empty-body.cpp
index bd6b47f053f..a248c4251d5 100644
--- a/clang/test/SemaCXX/warn-empty-body.cpp
+++ b/clang/test/SemaCXX/warn-empty-body.cpp
@@ -238,26 +238,6 @@ void test6(int x, int y) {
}
}
-void test_if_else(int x) {
- if (x); // expected-warning{{if statement has empty body}} expected-note{{separate line}}
-
- if (x)
- ; // no-warning
-
- if (x)
- ; // no-warning
- else
- ; // no-warning
-
- if (x)
- ; // no-warning
- else; // expected-warning{{else clause has empty body}} expected-note{{separate line}}
-
- if (x)
- ; // no-warning
- else EMPTY(x); // no-warning
-}
-
void test_errors(int x) {
if (1)
aa; // expected-error{{use of undeclared identifier}}
OpenPOWER on IntegriCloud