r200521 - [Sema] For -Wnon-literal-null-conversion warning, look through integer casts, which are used
Argyrios Kyrtzidis
akyrtzi at gmail.com
Sat Feb 1 21:33:01 PST 2014
On Feb 1, 2014, at 7:42 PM, James Dennett <jdennett at googlers.com> wrote:
> On Sat, Feb 1, 2014 at 6:05 PM, Dmitri Gribenko <gribozavr at gmail.com> wrote:
>> On Fri, Jan 31, 2014 at 7:51 AM, Argyrios Kyrtzidis <akyrtzi at gmail.com> wrote:
>>> Author: akirtzidis
>>> Date: Fri Jan 31 01:51:32 2014
>>> New Revision: 200521
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=200521&view=rev
>>> Log:
>>> [Sema] For -Wnon-literal-null-conversion warning, look through integer casts, which are used
>>> by some projects in their null macro.
>>
>> Hi Argyrios,
>>
>> I wonder, why isn't this handled automatically by
>> Expr::isNullPointerConstant -- it should be evaluating the whole
>> constant expression in this case.
>>
>> Dmitri
>
> I think we might not want to do this (i.e., we may wish to revert the patch).
>
> A goal of -Wnon-literal-null-conversion is to match rules proposed for
> C++14 (and possibly C++11 as a fix for core defect 903), and in those
> rules only integer literals (and nullptr) are valid null pointer
> constants. The C++14 draft N3690 says "A null pointer constant is an
> integer literal (2.14.2) with value zero or a prvalue of type
> std::nullptr_t."
>
> The previous implementation of -Wnon-literal-null-conversion would
> warn those projects so that they could fix their code. With this
> change (r200521), their (newly) non-conforming code won't be
> diagnosed.
>
> Likely we need to improve the documentation of this diagnostic in any
> case. The best extant description seems to be the commit message from
> http://llvm.org/viewvc/llvm-project?view=revision&revision=161501,
> which says "...This is effectively a warning for code that violates
> core issue 903 & thus will become standard error in the future,
> hopefully."
Thank you for the feedback! I reverted the behavior change for C++ with r200622.
>
> -- James
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140201/6e20169b/attachment.html>
More information about the cfe-commits
mailing list