forked from OSchip/llvm-project
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:
parent
9f48354b71
commit
d6ea6bd2a3
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue