diff options
author | Richard Trieu <rtrieu@google.com> | 2011-05-29 19:59:02 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2011-05-29 19:59:02 +0000 |
commit | 1838ca5618bc6c84ca3d13d84717bf32d9862bb3 (patch) | |
tree | f08a6e38a1cbbec03136b7c07622edabede71c99 /lib | |
parent | e72c55b9a11be9f00fa3f66f7ad6b73b2814e963 (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.cpp | 7 |
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); |