Don't emit -Wunused-value warnings from macro expansions.
llvm-svn: 166522
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 3c8cbb5..68bce4b 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -2026,6 +2026,10 @@
}
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/clang/test/Sema/unused-expr.c b/clang/test/Sema/unused-expr.c
index 056d09a..6677e48 100644
--- a/clang/test/Sema/unused-expr.c
+++ b/clang/test/Sema/unused-expr.c
@@ -122,3 +122,10 @@
// 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