diff options
author | George Burgess IV <george.burgess.iv@gmail.com> | 2015-10-29 00:28:52 +0000 |
---|---|---|
committer | George Burgess IV <george.burgess.iv@gmail.com> | 2015-10-29 00:28:52 +0000 |
commit | 148e0d3d5d8dcb673b27509a3c4673fe204e5daa (patch) | |
tree | ce9e4e3ae21552a117c079c972a8535318364fad /clang/lib/Sema | |
parent | 69c3387bcc99e2886e921f9eef51d0c08ccdb272 (diff) | |
download | bcm5719-llvm-148e0d3d5d8dcb673b27509a3c4673fe204e5daa.tar.gz bcm5719-llvm-148e0d3d5d8dcb673b27509a3c4673fe204e5daa.zip |
[Sema] Implement -Wdouble-promotion for clang.
GCC has a warning called -Wdouble-promotion, which warns you when
an implicit conversion increases the width of a floating point type.
This is useful when writing code for architectures that can perform
hardware FP ops on floats, but must fall back to software emulation for
larger types (i.e. double, long double).
This fixes PR15109 <https://llvm.org/bugs/show_bug.cgi?id=15109>.
Thanks to Carl Norum for the patch!
llvm-svn: 251588
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index a8d882a635e..8d9a1b23bb4 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -7217,6 +7217,14 @@ void CheckImplicitConversion(Sema &S, Expr *E, QualType T, return; DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_float_precision); + + } + // ... or possibly if we're increasing rank, too + else if (TargetBT->getKind() > SourceBT->getKind()) { + if (S.SourceMgr.isInSystemMacro(CC)) + return; + + DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_double_promotion); } return; } |