Author: matthewbg
Date: Tue Oct 23 18:19:32 2012
New Revision: 166522
URL: http://llvm.org/viewvc/llvm-project?rev=166522&view=rev
Log:
Don't emit -Wunused-value warnings from macro expansions.
Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/test/Sema/unused-expr.c
Modified: cfe/trunk/lib/AST/Expr.cpp
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=166522&r1=166521&r2=166522&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Tue Oct 23 18:19:32 2012
@@ -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);
Modified: cfe/trunk/test/Sema/unused-expr.c
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/unused-expr.c?rev=166522&r1=166521&r2=166522&view=diff
==============================================================================
--- cfe/trunk/test/Sema/unused-expr.c (original)
+++ cfe/trunk/test/Sema/unused-expr.c Tue Oct 23 18:19:32 2012
@@ -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
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits