// 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);
return; // no empty body warning.
}
+// Don't warn about an empty body if is expanded from a macro.
+void f4(int i) {
+ #define BODY ;
+ if (i == i) // expected-warning{{self-comparison always evaluates to true}}
+ BODY
+ #undef BODY
+}
+