[cfe-commits] r41557 - /cfe/trunk/AST/Expr.cpp
Steve Naroff
snaroff at apple.com
Tue Aug 28 14:20:34 PDT 2007
Author: snaroff
Date: Tue Aug 28 16:20:34 2007
New Revision: 41557
URL: http://llvm.org/viewvc/llvm-project?rev=41557&view=rev
Log:
Teach Expr::isNullPointerConstant() about ImplicitCastExpr's.
This fixes the following (recent) regression noticed by Keith Bauer (thanks!).
void func(void *a);
main() {
void *p;
p = 0;
func(0);
}
..which now works as you would expect.
Modified:
cfe/trunk/AST/Expr.cpp
Modified: cfe/trunk/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Expr.cpp?rev=41557&r1=41556&r2=41557&view=diff
==============================================================================
--- cfe/trunk/AST/Expr.cpp (original)
+++ cfe/trunk/AST/Expr.cpp Tue Aug 28 16:20:34 2007
@@ -647,6 +647,14 @@
CE->getSubExpr()->getType()->isIntegerType()) // from int.
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);
+ }
} else if (const ParenExpr *PE = dyn_cast<ParenExpr>(this)) {
// Accept ((void*)0) as a null pointer constant, as many other
// implementations do.
More information about the cfe-commits
mailing list