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

Jordan Rose jordan_rose at apple.com
Tue Apr 22 13:19:19 PDT 2014


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




More information about the cfe-commits mailing list