aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2011-05-29 19:59:02 +0000
committerRichard Trieu <rtrieu@google.com>2011-05-29 19:59:02 +0000
commit1838ca5618bc6c84ca3d13d84717bf32d9862bb3 (patch)
treef08a6e38a1cbbec03136b7c07622edabede71c99 /lib
parente72c55b9a11be9f00fa3f66f7ad6b73b2814e963 (diff)
Add a new warning on NULL pointer constant to integer conversion.
This path was reviewed by Chandler Carruth at http://codereview.appspot.com/4538074/ git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132297 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Sema/SemaChecking.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 169b242cd9..7430cfb119 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -2968,6 +2968,13 @@ void CheckImplicitConversion(Sema &S, Expr *E, QualType T,
if (!Source->isIntegerType() || !Target->isIntegerType())
return;
+ if ((E->isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNotNull)
+ == Expr::NPCK_GNUNull) && Target->isIntegerType()) {
+ S.Diag(E->getExprLoc(), diag::warn_impcast_null_pointer_to_integer)
+ << E->getSourceRange() << clang::SourceRange(CC);
+ return;
+ }
+
IntRange SourceRange = GetExprRange(S.Context, E);
IntRange TargetRange = IntRange::forTargetOfCanonicalType(S.Context, Target);