diff options
author | David Blaikie <dblaikie@gmail.com> | 2012-06-19 21:19:06 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2012-06-19 21:19:06 +0000 |
commit | 9366d2b32d0b5e20a882fc675345e02f0a7e18dd (patch) | |
tree | ba3e9ac5bab0f616254071e9cd1de96da2ba30af /clang/lib/Sema/SemaChecking.cpp | |
parent | 0f855e42630306e01cf8873b9eb965b7ea6c09fd (diff) | |
download | bcm5719-llvm-9366d2b32d0b5e20a882fc675345e02f0a7e18dd.tar.gz bcm5719-llvm-9366d2b32d0b5e20a882fc675345e02f0a7e18dd.zip |
Enable -Wnull-conversion for non-integral target types (eg: double).
llvm-svn: 158744
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 11 |
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)) |