]> granicus.if.org Git - clang/commitdiff
Don't emit -Wunused-value warnings from macro expansions.
authorMatt Beaumont-Gay <matthewbg@google.com>
Tue, 23 Oct 2012 23:19:32 +0000 (23:19 +0000)
committerMatt Beaumont-Gay <matthewbg@google.com>
Tue, 23 Oct 2012 23:19:32 +0000 (23:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166522 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Expr.cpp
test/Sema/unused-expr.c

index 3c8cbb56a0252f03be5f20a60f290a0eba0acb52..68bce4b6f653a1f1ce203aee6f4fce0618bba831 100644 (file)
@@ -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);
index 056d09a8713bb0cdaec2aff1aa7bb45cbb1e172a..6677e48300a59793f1706ad9ef62441bfd76a8a5 100644 (file)
@@ -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