diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-09-16 00:37:05 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-09-16 00:37:05 +0000 |
commit | b3198178daf9d33466fc18e009e2c6692fdf29c0 (patch) | |
tree | 729113bc2c1687c16afd037fd67561229a03d5f1 /lib/Sema/SemaStmt.cpp | |
parent | 474e2fe4957e6e72cee36ed189eaf21878ad0e91 (diff) |
Do not warn about empty bodies for 'if' statements if the body is expanded from a macro.
Fixes <rdar://problem/8436021>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114049 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 84dfa1a999..c9a6da13fb 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -272,9 +272,12 @@ Sema::ActOnIfStmt(SourceLocation IfLoc, FullExprArg CondVal, Decl *CondVar, // this helps prevent bugs due to typos, such as // if (condition); // do_stuff(); + // + // NOTE: Do not emit this warning if the body is expanded from a macro. if (!elseStmt) { if (NullStmt* stmt = dyn_cast<NullStmt>(thenStmt)) - Diag(stmt->getSemiLoc(), diag::warn_empty_if_body); + if (!stmt->getLocStart().isMacroID()) + Diag(stmt->getSemiLoc(), diag::warn_empty_if_body); } DiagnoseUnusedExprResult(elseStmt); |