From 9366d2b32d0b5e20a882fc675345e02f0a7e18dd Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Tue, 19 Jun 2012 21:19:06 +0000 Subject: Enable -Wnull-conversion for non-integral target types (eg: double). llvm-svn: 158744 --- clang/lib/Sema/SemaChecking.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'clang/lib/Sema/SemaChecking.cpp') 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)) -- cgit v1.2.3