-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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
- Loading branch information
1 parent
69c3387
commit 148e0d3
Showing
4 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| // RUN: %clang_cc1 -verify -fsyntax-only %s -Wdouble-promotion | ||
|
|
||
| float ReturnFloatFromDouble(double d) { | ||
| return d; | ||
| } | ||
|
|
||
| float ReturnFloatFromLongDouble(long double ld) { | ||
| return ld; | ||
| } | ||
|
|
||
| double ReturnDoubleFromLongDouble(long double ld) { | ||
| return ld; | ||
| } | ||
|
|
||
| double ReturnDoubleFromFloat(float f) { | ||
| return f; //expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}} | ||
| } | ||
|
|
||
| long double ReturnLongDoubleFromFloat(float f) { | ||
| return f; //expected-warning{{implicit conversion increases floating-point precision: 'float' to 'long double'}} | ||
| } | ||
|
|
||
| long double ReturnLongDoubleFromDouble(double d) { | ||
| return d; //expected-warning{{implicit conversion increases floating-point precision: 'double' to 'long double'}} | ||
| } | ||
|
|
||
| void Convert(float f, double d, long double ld) { | ||
| d = f; //expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}} | ||
| ld = f; //expected-warning{{implicit conversion increases floating-point precision: 'float' to 'long double'}} | ||
| ld = d; //expected-warning{{implicit conversion increases floating-point precision: 'double' to 'long double'}} | ||
| f = d; | ||
| f = ld; | ||
| d = ld; | ||
| } |