summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r--clang/lib/Sema/SemaChecking.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 41ac77b43be..fff8d80a477 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -4279,11 +4279,10 @@ void CheckImplicitConversion(Sema &S, Expr *E, QualType T,
return;
}
- if (!Source->isIntegerType() || !Target->isIntegerType())
- return;
-
if ((E->isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNotNull)
- == Expr::NPCK_GNUNull) && Target->isIntegerType()) {
+ == Expr::NPCK_GNUNull) && !Target->isAnyPointerType()
+ && !Target->isBlockPointerType() && !Target->isFunctionPointerType()
+ && !Target->isMemberFunctionPointerType()) {
SourceLocation Loc = E->getSourceRange().getBegin();
if (Loc.isMacroID())
Loc = S.SourceMgr.getImmediateExpansionRange(Loc).first;
@@ -4291,9 +4290,11 @@ void CheckImplicitConversion(Sema &S, Expr *E, QualType T,
S.Diag(Loc, diag::warn_impcast_null_pointer_to_integer)
<< T << clang::SourceRange(CC)
<< FixItHint::CreateReplacement(Loc, S.getFixItZeroLiteralForType(T));
- return;
}
+ if (!Source->isIntegerType() || !Target->isIntegerType())
+ return;
+
// TODO: remove this early return once the false positives for constant->bool
// in templates, macros, etc, are reduced or removed.
if (Target->isSpecificBuiltinType(BuiltinType::Bool))
OpenPOWER on IntegriCloud