Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(240)

Unified Diff: lib/Sema/SemaChecking.cpp

Issue 4538074: Warn on NULL to integer conversion (Closed) Base URL: https://llvm.org/svn/llvm-project/cfe/trunk/
Patch Set: Updating base revision. Created 13 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/clang/Basic/DiagnosticSemaKinds.td ('k') | test/SemaCXX/conversion.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/Sema/SemaChecking.cpp
===================================================================
--- lib/Sema/SemaChecking.cpp (revision 132294)
+++ lib/Sema/SemaChecking.cpp (working copy)
@@ -2968,6 +2968,13 @@
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);
« no previous file with comments | « include/clang/Basic/DiagnosticSemaKinds.td ('k') | test/SemaCXX/conversion.cpp » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b