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

Chandler Carruth chandlerc at google.com
Thu Feb 17 01:00:27 PST 2011


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110217/52a7b44c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: warn_literal_conversion.patch
Type: text/x-patch
Size: 5843 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110217/52a7b44c/attachment.bin>


More information about the cfe-commits mailing list