[cfe-commits] r77344 - in /cfe/trunk: lib/AST/Expr.cpp test/Sema/unused-expr.c
Chris Lattner
sabre at nondot.org
Tue Jul 28 11:25:29 PDT 2009
Author: lattner
Date: Tue Jul 28 13:25:28 2009
New Revision: 77344
URL: http://llvm.org/viewvc/llvm-project?rev=77344&view=rev
Log:
fix PR4633: cast to void should silence the 'unused expression' warning.
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=77344&r1=77343&r2=77344&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Tue Jul 28 13:25:28 2009
@@ -593,11 +593,10 @@
return true;
}
case CStyleCastExprClass:
- // If this is a cast to void, check the operand. Otherwise, the result of
- // the cast is unused.
+ // If this is an explicit cast to void, allow it. People do this when they
+ // think they know what they're doing :).
if (getType()->isVoidType())
- return cast<CastExpr>(this)->getSubExpr()
- ->isUnusedResultAWarning(Loc, R1, R2);
+ return false;
Loc = cast<CStyleCastExpr>(this)->getLParenLoc();
R1 = cast<CStyleCastExpr>(this)->getSubExpr()->getSourceRange();
return true;
Modified: cfe/trunk/test/Sema/unused-expr.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/unused-expr.c?rev=77344&r1=77343&r2=77344&view=diff
==============================================================================
--- cfe/trunk/test/Sema/unused-expr.c (original)
+++ cfe/trunk/test/Sema/unused-expr.c Tue Jul 28 13:25:28 2009
@@ -43,4 +43,11 @@
{
unsigned char c = 1;
*a |= c, *b += c;
+
+
+ // PR4633
+ int y, x;
+ ((void)0), y = x;
}
+
+
More information about the cfe-commits
mailing list