r206832 - Move the warning of implicit cast of a floating point to an integer out of

Richard Trieu rtrieu at google.com
Tue Apr 22 15:20:55 PDT 2014


Floating point sounded like a pretty descriptive name when I chose it.  I
do see your point, a shorter warning name is usually preferred over a
longer name.

Float:
-Wfloat-equal
-Wgnu-static-float-init
-Wstatic-float-init

Floating Point:
-Wimplicit-conversion-floating-point-to-bool

Existing warnings also show a preference for float.  I will change this
warning to float as well to be consistent.



On Tue, Apr 22, 2014 at 1:19 PM, Jordan Rose <jordan_rose at apple.com> wrote:

> Name bikeshed: why -Wfloating-point-conversion and not -Wfloat-conversion?
> The other warnings are -Wbool-conversion and -Wint-conversion, not
> -Wboolean-conversion and -Winteger-conversion, and the latter covers other
> integer sizes as well. (Admittedly, though, you can say "unsigned short
> int" but not "double float".)
>
> Jordan
>
>
> On Apr 21, 2014, at 18:01 , Richard Trieu <rtrieu at google.com> wrote:
>
> > Author: rtrieu
> > Date: Mon Apr 21 20:01:05 2014
> > New Revision: 206832
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=206832&view=rev
> > Log:
> > Move the warning of implicit cast of a floating point to an integer out
> of
> > -Wconversion and into it's own group, -Wfloating-point-conversion.
> >
> > Added:
> >    cfe/trunk/test/SemaCXX/warn-floating-point-conversion.cpp
> > Modified:
> >    cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> >    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> >
> > Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=206832&r1=206831&r2=206832&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
> > +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Mon Apr 21
> 20:01:05 2014
> > @@ -41,6 +41,7 @@ def PointerBoolConversion : DiagGroup<"p
> > def BoolConversion : DiagGroup<"bool-conversion", [
> PointerBoolConversion ] >;
> > def IntConversion : DiagGroup<"int-conversion">;
> > def EnumConversion : DiagGroup<"enum-conversion">;
> > +def FloatingPointConversion : DiagGroup<"floating-point-conversion">;
> > def EnumTooLarge : DiagGroup<"enum-too-large">;
> > def NonLiteralNullConversion : DiagGroup<"non-literal-null-conversion">;
> > def NullConversion : DiagGroup<"null-conversion">;
> > @@ -476,6 +477,7 @@ def Conversion : DiagGroup<"conversion",
> >                            [BoolConversion,
> >                             ConstantConversion,
> >                             EnumConversion,
> > +                            FloatingPointConversion,
> >                             Shorten64To32,
> >                             IntConversion,
> >                             LiteralConversion,
> >
> > Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=206832&r1=206831&r2=206832&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> > +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Apr 21
> 20:01:05 2014
> > @@ -2319,7 +2319,7 @@ def warn_impcast_float_precision : Warni
> >   InGroup<Conversion>, DefaultIgnore;
> > def warn_impcast_float_integer : Warning<
> >   "implicit conversion turns floating-point number into integer: %0 to
> %1">,
> > -  InGroup<Conversion>, DefaultIgnore;
> > +  InGroup<FloatingPointConversion>, DefaultIgnore;
> > def warn_impcast_integer_sign : Warning<
> >   "implicit conversion changes signedness: %0 to %1">,
> >   InGroup<SignConversion>, DefaultIgnore;
> >
> > Added: cfe/trunk/test/SemaCXX/warn-floating-point-conversion.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-floating-point-conversion.cpp?rev=206832&view=auto
> >
> ==============================================================================
> > --- cfe/trunk/test/SemaCXX/warn-floating-point-conversion.cpp (added)
> > +++ cfe/trunk/test/SemaCXX/warn-floating-point-conversion.cpp Mon Apr 21
> 20:01:05 2014
> > @@ -0,0 +1,38 @@
> > +// RUN: %clang_cc1 -verify -fsyntax-only %s -Wfloating-point-conversion
> > +
> > +bool ReturnBool(float f) {
> > +  return f;  //expected-warning{{conversion}}
> > +}
> > +
> > +char ReturnChar(float f) {
> > +  return f;  //expected-warning{{conversion}}
> > +}
> > +
> > +int ReturnInt(float f) {
> > +  return f;  //expected-warning{{conversion}}
> > +}
> > +
> > +long ReturnLong(float f) {
> > +  return f;  //expected-warning{{conversion}}
> > +}
> > +
> > +void Convert(float f, double d, long double ld) {
> > +  bool b;
> > +  char c;
> > +  int i;
> > +  long l;
> > +
> > +  b = f;  //expected-warning{{conversion}}
> > +  b = d;  //expected-warning{{conversion}}
> > +  b = ld;  //expected-warning{{conversion}}
> > +  c = f;  //expected-warning{{conversion}}
> > +  c = d;  //expected-warning{{conversion}}
> > +  c = ld;  //expected-warning{{conversion}}
> > +  i = f;  //expected-warning{{conversion}}
> > +  i = d;  //expected-warning{{conversion}}
> > +  i = ld;  //expected-warning{{conversion}}
> > +  l = f;  //expected-warning{{conversion}}
> > +  l = d;  //expected-warning{{conversion}}
> > +  l = ld;  //expected-warning{{conversion}}
> > +}
> > +
> >
> >
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140422/85f3084e/attachment.html>


More information about the cfe-commits mailing list