[cfe-commits] [PATCH] -Wconversion-null

Lubos Lunak l.lunak at suse.cz
Tue Mar 13 22:53:04 PDT 2012


On Tuesday 13 of March 2012, David Blaikie wrote:
> On Tue, Mar 13, 2012 at 3:24 PM, David Blaikie <dblaikie at gmail.com> wrote:
> > If you're going to provide a tblgen name for the ConversionNull group,
> > perhaps you could define it above the Conversion group & use the
> > ConversionNull name (rather than using the "conversion-null" string
> > separately/twice) in Conversion's definition.
>
> And reuse the ConversionNull named group in DiagnosticSemaKinds.td
> too. The "conversion-null" string should be written once rather than
> three times.

 Updated patch attached.

> > It's probably OK to remove the "DefaultIgnore" flag for this patch
> > too, again to be consistent with GCC (which has this warning on by
> > default).
>
> Hmm, weird - I'm looking at the DiagnosticSemaKinds.td & I'm not sure
> why this warning is actually on by default & your test case is
> passing. (assuming it is)

 It is actually not. I simply copy&pasted it to a separate file, and I 
ran 'make check', which ran LLVM's checks, and 'make unittest' in clang/, 
which didn't run the tests in tests/ either. The NULL tests pass with the 
updated patch when I run 'make' in clang/tests/.

> > One caveat is that this warning is currently a little bit broken in
> > Clang. If you initialize an integer of the same size as a pointer, the
> > warning will not be provided. i.e. only one warning is produced from:
> >
> > int i = __null;
> > long l = __null;
> >
> > (__null is the special null value that GNU's stdlib defines NULL to be
> > & how it detects this case) depending on whether you have a 32 bit or
> > 64 bit pointer (assuming you have one of those and that int is 32 bits
> > and long is 64). That's something to fix at some point...

 I see. I'll leave that as a separate issue.

-- 
 Lubos Lunak
 l.lunak at suse.cz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang-conversion-null.patch
Type: text/x-diff
Size: 5453 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120314/6899c573/attachment.patch>


More information about the cfe-commits mailing list