[Sema] Follow-up on r200521 for the -Wnon-literal-null-conversion warning and revert its behavior for C++.
llvm-svn: 200622
This commit is contained in:
parent
17455633c7
commit
3e3305daba
|
@ -3061,6 +3061,9 @@ Expr::isNullPointerConstant(ASTContext &Ctx,
|
|||
Pointee->isVoidType() && // to void*
|
||||
CE->getSubExpr()->getType()->isIntegerType()) // from int.
|
||||
return CE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
|
||||
// Or an integer cast.
|
||||
} else if (CE->getType()->isIntegerType()) {
|
||||
return CE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
|
||||
}
|
||||
}
|
||||
} else if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(this)) {
|
||||
|
|
|
@ -2622,19 +2622,6 @@ bool Sema::FunctionParamTypesAreEqual(const FunctionProtoType *OldType,
|
|||
return true;
|
||||
}
|
||||
|
||||
static Expr *ignoreIntegerCasts(Expr *E) {
|
||||
while (true) {
|
||||
if (ExplicitCastExpr *ECE = dyn_cast<ExplicitCastExpr>(E)) {
|
||||
if (ECE->getType()->isIntegerType()) {
|
||||
E = ECE->getSubExpr();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return E;
|
||||
}
|
||||
}
|
||||
|
||||
/// CheckPointerConversion - Check the pointer conversion from the
|
||||
/// expression From to the type ToType. This routine checks for
|
||||
/// ambiguous or inaccessible derived-to-base pointer
|
||||
|
@ -2651,8 +2638,7 @@ bool Sema::CheckPointerConversion(Expr *From, QualType ToType,
|
|||
Kind = CK_BitCast;
|
||||
|
||||
if (!IsCStyleOrFunctionalCast && !FromType->isAnyPointerType() &&
|
||||
ignoreIntegerCasts(From)->
|
||||
isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNotNull) ==
|
||||
From->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNotNull) ==
|
||||
Expr::NPCK_ZeroExpression) {
|
||||
if (Context.hasSameUnqualifiedType(From->getType(), Context.BoolTy))
|
||||
DiagRuntimeBehavior(From->getExprLoc(), From,
|
||||
|
|
Loading…
Reference in New Issue