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

Issue 4861041: Make a more descriptive warning when comparing NULL with non-pointer (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 9 months ago by rtrieu
Modified:
12 years, 9 months ago
Reviewers:
chandlerc
Base URL:
https://llvm.org/svn/llvm-project/cfe/trunk/
Visibility:
Public.

Description

Committed at revision 137377

Patch Set 1 #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+15 lines, -10 lines) Patch
M include/clang/Basic/DiagnosticSemaKinds.td View 1 chunk +4 lines, -0 lines 2 comments Download
M lib/Sema/SemaExpr.cpp View 1 chunk +4 lines, -3 lines 0 comments Download
M test/SemaCXX/null_in_arithmetic_ops.cpp View 2 chunks +7 lines, -7 lines 0 comments Download

Messages

Total messages: 2
chandlerc
http://codereview.appspot.com/4861041/diff/1/include/clang/Basic/DiagnosticSemaKinds.td File include/clang/Basic/DiagnosticSemaKinds.td (right): http://codereview.appspot.com/4861041/diff/1/include/clang/Basic/DiagnosticSemaKinds.td#newcode3168 include/clang/Basic/DiagnosticSemaKinds.td:3168: "%select{(%1 and NULL)|(NULL and %1)}0">, Why repeat the NULL ...
12 years, 9 months ago (2011-08-11 01:32:13 UTC) #1
rtrieu
12 years, 9 months ago (2011-08-11 01:44:30 UTC) #2
http://codereview.appspot.com/4861041/diff/1/include/clang/Basic/DiagnosticSe...
File include/clang/Basic/DiagnosticSemaKinds.td (right):

http://codereview.appspot.com/4861041/diff/1/include/clang/Basic/DiagnosticSe...
include/clang/Basic/DiagnosticSemaKinds.td:3168: "%select{(%1 and NULL)|(NULL
and %1)}0">,
On 2011/08/11 01:32:14, chandlerc wrote:
> Why repeat the NULL here? Maybe just "... between NULL and non-pointer %1'.
Also
> I wonder if we want to spell NULL the way the user did (NULL vs. (void*)0 vs.
> nullptr).

The NULL is repeated since many other warnings on binary operations will have
('type1' and 'type2') so this is to be consistent with them.

This warning checks for a GNUNullExpr, so it won't trigger on (void*)0 or
nullptr.  In those cases, a separate error will be emitted.  I believe it will
trigger on __null, but I don't think that is commonly used.
Sign in to reply to this message.

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