aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2007-08-29 00:00:02 +0000
committerSteve Naroff <snaroff@apple.com>2007-08-29 00:00:02 +0000
commit19a6ebd216041c6f466ea18a8b1bbdd9e7ea1649 (patch)
tree54d1f5690da2f591c161bd7400d68203d776eeb2
parentb291ab60474e8f02f5d1245f77d3af31bcd4821c (diff)
Re-teach Expr::isNullPointerConstant() about ImplicitCastExpr:-)
This fixes the following bug submitted by Neil... const char *f (void) { return 0; } ...which would incorrectly warn with -pedantic enabled. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41559 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--AST/Expr.cpp9
1 files changed, 2 insertions, 7 deletions
diff --git a/AST/Expr.cpp b/AST/Expr.cpp
index 69ea9442ff..0b284a8a3f 100644
--- a/AST/Expr.cpp
+++ b/AST/Expr.cpp
@@ -648,13 +648,8 @@ bool Expr::isNullPointerConstant(ASTContext &Ctx) const {
return CE->getSubExpr()->isNullPointerConstant(Ctx);
}
} else if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(this)) {
- // Check that it is a cast to void*.
- if (const PointerType *PT = dyn_cast<PointerType>(ICE->getType())) {
- QualType Pointee = PT->getPointeeType();
- if (Pointee.getQualifiers() == 0 && Pointee->isVoidType() && // to void*
- ICE->getSubExpr()->getType()->isIntegerType()) // from int.
- return ICE->getSubExpr()->isNullPointerConstant(Ctx);
- }
+ // Ignore the ImplicitCastExpr type entirely.
+ return ICE->getSubExpr()->isNullPointerConstant(Ctx);
} else if (const ParenExpr *PE = dyn_cast<ParenExpr>(this)) {
// Accept ((void*)0) as a null pointer constant, as many other
// implementations do.