aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2012-06-19 21:19:06 +0000
committerDavid Blaikie <dblaikie@gmail.com>2012-06-19 21:19:06 +0000
commitb26331b4ff419b22861b0823daf83bc8f22a6803 (patch)
treec867fc2c57c8172837cd8d0106c3c7f6ce6f56f5 /lib/Sema/SemaChecking.cpp
parent7ba759237afee52f4d53ed1fe07dbfdcfdbabdc6 (diff)
Enable -Wnull-conversion for non-integral target types (eg: double).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158744 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r--lib/Sema/SemaChecking.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 41ac77b43b..fff8d80a47 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/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))