diff options
author | Richard Trieu <rtrieu@google.com> | 2011-08-11 22:38:21 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2011-08-11 22:38:21 +0000 |
commit | 79e610a99b43b9e6df8f9b6b59dbaf5d38a682d3 (patch) | |
tree | 26759277af144c656ed7b30de046450eb3d28cca /lib/Sema/SemaExpr.cpp | |
parent | 5f95728e0d37709402ab83abe085f40686a4007b (diff) |
The current warning in -Wnull-arithmetic for comparisons between NULL and non-pointers is not very helpful. This patch will update the wording to be more helpful to users.
Old warning:
warning: use of NULL in arithmetic operation [-Wnull-arithmetic]
return 10 <= NULL;
^ ~~~~
New warning:
warning: comparison between NULL and non-pointer ('int' and NULL) [-Wnull-arithmetic]
return 10 <= NULL;
~~ ^ ~~~~
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137377 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index d78c4962a4..efc05de90e 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -7626,9 +7626,10 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc, !LeftType->canDecayToPointerType() && !RightType->isAnyPointerType() && !RightType->canDecayToPointerType()) { - Diag(OpLoc, diag::warn_null_in_arithmetic_operation) - << (LeftNull ? lhs.get()->getSourceRange() - : rhs.get()->getSourceRange()); + Diag(OpLoc, diag::warn_null_in_comparison_operation) + << LeftNull /* LHS is NULL */ + << (LeftNull ? rhs.get()->getType() : lhs.get()->getType()) + << lhs.get()->getSourceRange() << rhs.get()->getSourceRange(); } } } |