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. llvm-svn: 41559
This commit is contained in:
parent
0b66158248
commit
c5e5027b86
|
@ -648,13 +648,8 @@ bool Expr::isNullPointerConstant(ASTContext &Ctx) const {
|
||||||
return CE->getSubExpr()->isNullPointerConstant(Ctx);
|
return CE->getSubExpr()->isNullPointerConstant(Ctx);
|
||||||
}
|
}
|
||||||
} else if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(this)) {
|
} else if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(this)) {
|
||||||
// Check that it is a cast to void*.
|
// Ignore the ImplicitCastExpr type entirely.
|
||||||
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);
|
return ICE->getSubExpr()->isNullPointerConstant(Ctx);
|
||||||
}
|
|
||||||
} else if (const ParenExpr *PE = dyn_cast<ParenExpr>(this)) {
|
} else if (const ParenExpr *PE = dyn_cast<ParenExpr>(this)) {
|
||||||
// Accept ((void*)0) as a null pointer constant, as many other
|
// Accept ((void*)0) as a null pointer constant, as many other
|
||||||
// implementations do.
|
// implementations do.
|
||||||
|
|
Loading…
Reference in New Issue