diff options
author | Matt Beaumont-Gay <matthewbg@google.com> | 2012-10-23 23:19:32 +0000 |
---|---|---|
committer | Matt Beaumont-Gay <matthewbg@google.com> | 2012-10-23 23:19:32 +0000 |
commit | c7db84d0146a6f22b19949fb0128e2148aa92467 (patch) | |
tree | 9d33b6e3660b2720a4d246b01bc9c77ac56443a7 | |
parent | f27762b1beced898e47aeae1bcb557addd8a148d (diff) |
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
-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 |