fix PR4633: cast to void should silence the 'unused expression' warning.

llvm-svn: 77344
This commit is contained in:
Chris Lattner 2009-07-28 18:25:28 +00:00
parent 1d0f16f22a
commit 2706a55071
2 changed files with 10 additions and 4 deletions

View File

@ -593,11 +593,10 @@ bool Expr::isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1,
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;

View File

@ -43,4 +43,11 @@ void nowarn(unsigned char* a, unsigned char* b)
{
unsigned char c = 1;
*a |= c, *b += c;
// PR4633
int y, x;
((void)0), y = x;
}