summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/AST/Expr.cpp7
-rw-r--r--clang/test/Sema/unused-expr.c7
2 files changed, 10 insertions, 4 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 2c473ebc428..79ebb546d07 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -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;
diff --git a/clang/test/Sema/unused-expr.c b/clang/test/Sema/unused-expr.c
index 9c231e960a2..a5e5ec4e149 100644
--- a/clang/test/Sema/unused-expr.c
+++ b/clang/test/Sema/unused-expr.c
@@ -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;
}
+
+
OpenPOWER on IntegriCloud