r200622 - [Sema] Follow-up on r200521 for the -Wnon-literal-null-conversion warning and revert its behavior for C++.
Argyrios Kyrtzidis
akyrtzi at gmail.com
Sat Feb 1 21:26:44 PST 2014
Author: akirtzidis
Date: Sat Feb 1 23:26:43 2014
New Revision: 200622
URL: http://llvm.org/viewvc/llvm-project?rev=200622&view=rev
Log:
[Sema] Follow-up on r200521 for the -Wnon-literal-null-conversion warning and revert its behavior for C++.
Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=200622&r1=200621&r2=200622&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Sat Feb 1 23:26:43 2014
@@ -3061,6 +3061,9 @@ Expr::isNullPointerConstant(ASTContext &
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)) {
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=200622&r1=200621&r2=200622&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Sat Feb 1 23:26:43 2014
@@ -2622,19 +2622,6 @@ bool Sema::FunctionParamTypesAreEqual(co
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 *
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,
More information about the cfe-commits
mailing list