]> granicus.if.org Git - clang/commit
Split interesting warnings off from -Wfloat-conversion
authorRichard Trieu <rtrieu@google.com>
Thu, 21 Apr 2016 21:04:55 +0000 (21:04 +0000)
committerRichard Trieu <rtrieu@google.com>
Thu, 21 Apr 2016 21:04:55 +0000 (21:04 +0000)
commit3c188bce6b37bf75d728943bb208415b018134db
tree2850a412add9e8a1861985ac89fe0f7072d07ad3
parent628d5cb321544e5ebe0143e62b40ef4aed773b92
Split interesting warnings off from -Wfloat-conversion

Restructure the implict floating point to integer conversions so that
interesting sub-groups are under different flags.  Breakdown of warnings:

No warning:
Exact conversions from floating point to integer:
int x = 10.0;
int x = 1e10;

-Wliteral-conversion - Floating point literal to integer with rounding:
int x = 5.5;
int x = -3.4;

-Wfloat-conversion - All conversions not covered by the above two:
int x = GetFloat();
int x = 5.5 + 3.5;

-Wfloat-zero-conversion - The expression converted has a non-zero floating
point value that gets converted to a zero integer value, excluded the cases
falling under -Wliteral-conversion.  Subset of -Wfloat-conversion.
int x = 1.0 / 2.0;

-Wfloat-overflow-conversion - The floating point value is outside the range
of the integer type, exluding cases from -Wliteral conversion.  Subset of
-Wfloat-conversion.
char x = 500;
char x = -1000;

-Wfloat-bool-conversion - Any conversion of a floating point type to bool.
Subset of -Wfloat-conversion.
if (GetFloat()) {}
bool x = 5.0;

-Wfloat-bool-constant-conversion - Conversion of a compile time evaluatable
floating point value to bool.  Subset of -Wfloat-bool-conversion.
bool x = 1.0;
bool x = 4.0 / 20.0;

Also add EvaluateAsFloat to Sema, which is similar to EvaluateAsInt, but for
floating point values.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@267054 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/AST/Expr.h
include/clang/Basic/DiagnosticGroups.td
include/clang/Basic/DiagnosticSemaKinds.td
lib/AST/ExprConstant.cpp
lib/Sema/SemaChecking.cpp
test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
test/SemaCXX/warn-float-conversion.cpp
test/SemaCXX/warn-literal-conversion.cpp