Don't emit -Wunused-value warnings from macro expansions.

llvm-svn: 166522
This commit is contained in:
Matt Beaumont-Gay 2012-10-23 23:19:32 +00:00
parent 949cc50962
commit 493d6d55ba
2 changed files with 11 additions and 0 deletions

View File

@ -2026,6 +2026,10 @@ bool Expr::isUnusedResultAWarning(const Expr *&WarnE, SourceLocation &Loc,
} }
case CXXFunctionalCastExprClass: case CXXFunctionalCastExprClass:
case CStyleCastExprClass: { case CStyleCastExprClass: {
// Ignore casts within macro expansions.
if (getExprLoc().isMacroID())
return false;
// Ignore an explicit cast to void unless the operand is a non-trivial // Ignore an explicit cast to void unless the operand is a non-trivial
// volatile lvalue. // volatile lvalue.
const CastExpr *CE = cast<CastExpr>(this); const CastExpr *CE = cast<CastExpr>(this);

View File

@ -122,3 +122,10 @@ void f(int i, ...) {
// PR8371 // PR8371
int fn5() __attribute__ ((__const)); int fn5() __attribute__ ((__const));
// OpenSSL has some macros like this.
#define M(a, b) (long)foo((a), (b))
void t11(int i, int j) {
M(i, j); // no warning
}
#undef M