From: Matt Beaumont-Gay Date: Tue, 23 Oct 2012 23:19:32 +0000 (+0000) Subject: Don't emit -Wunused-value warnings from macro expansions. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c7db84d0146a6f22b19949fb0128e2148aa92467;p=clang Don't emit -Wunused-value warnings from macro expansions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166522 91177308-0d34-0410-b5e6-96231b3b80d8 --- 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(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