[cfe-commits] PATCH: Add -Wliteral-conversion to Clang

John McCall rjmccall at apple.com
Thu Feb 17 02:14:18 PST 2011


On Feb 17, 2011, at 1:00 AM, Chandler Carruth wrote:

> On Tue, Feb 15, 2011 at 10:35 PM, John McCall <rjmccall at apple.com> wrote:
> On Feb 15, 2011, at 10:13 PM, Chandler Carruth wrote:
> > This warning works similarly to -Wconversion, but (currently) only fires on literal floating point values used to initialize an integer variable. It can be expanded to cover more conversions as needed. These often occur due to syntaxes like "10e5" which can surprise users as a double.
> >
> > Thoughts? This look reasonable?
> 
> It's interesting.  I have no problem with adding it for people who aren't willing to turn on proper -Wconversion, but it should at least be a subgroup of that.
> 
> Done.
>  
> Also, the message might as well be consistent with the existing -Wconversion messages, not because I'm claiming that they're something wonderful but just because my little mind needs more hobgoblins.  Something like:
>  implicit conversion turns literal floating-point number into integer: 'double' to 'int'
> or maybe even using the exact same message, but in a different warning group.
> 
> Used the same message structure, only added the word 'literal'. If i can *actually* use the same message, and just turn on that word with a select, I'm ok doing that too. I didn't see an obvious way to either control the group in that fashion, and the code is factored such that it'd be awkward (but not impossible) to thread the literal flag down through the levels, so I left it at a separate but compatibly worded message.
> <warn_literal_conversion.patch>

This looks fine, thanks!

John.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110217/18824398/attachment.html>


More information about the cfe-commits mailing list