forked from OSchip/llvm-project
fix PR4633: cast to void should silence the 'unused expression' warning.
llvm-svn: 77344
This commit is contained in:
parent
1d0f16f22a
commit
2706a55071
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue