Don't warn with -Wbool-conversions if the user wrote an explicit cast like "(void *)false".

Fixes rdar://8459342.

llvm-svn: 114955
This commit is contained in:
Argyrios Kyrtzidis 2010-09-28 14:54:11 +00:00
parent 9f48354b71
commit d6ea6bd2a3
2 changed files with 3 additions and 1 deletions

View File

@ -1728,10 +1728,11 @@ bool Sema::CheckPointerConversion(Expr *From, QualType ToType,
CXXCastPath& BasePath,
bool IgnoreBaseAccess) {
QualType FromType = From->getType();
bool IsCStyleOrFunctionalCast = IgnoreBaseAccess;
if (CXXBoolLiteralExpr* LitBool
= dyn_cast<CXXBoolLiteralExpr>(From->IgnoreParens()))
if (LitBool->getValue() == false)
if (!IsCStyleOrFunctionalCast && LitBool->getValue() == false)
Diag(LitBool->getExprLoc(), diag::warn_init_pointer_from_false)
<< ToType;

View File

@ -5,5 +5,6 @@ int* j = false; // expected-warning{{ initialization of pointer of type 'int *'
void foo(int* i, int *j=(false)) // expected-warning{{ initialization of pointer of type 'int *' from literal 'false'}}
{
foo(false); // expected-warning{{ initialization of pointer of type 'int *' from literal 'false'}}
foo((int*)false);
}