diff options
-rw-r--r-- | lib/AST/Expr.cpp | 4 | ||||
-rw-r--r-- | test/Sema/unused-expr.c | 7 |
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 3c8cbb56a0..68bce4b6f6 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -2026,6 +2026,10 @@ bool Expr::isUnusedResultAWarning(const Expr *&WarnE, SourceLocation &Loc, } case CXXFunctionalCastExprClass: 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 // volatile lvalue. const CastExpr *CE = cast<CastExpr>(this); diff --git a/test/Sema/unused-expr.c b/test/Sema/unused-expr.c index 056d09a871..6677e48300 100644 --- a/test/Sema/unused-expr.c +++ b/test/Sema/unused-expr.c @@ -122,3 +122,10 @@ void f(int i, ...) { // PR8371 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 |