aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2009-12-24 11:09:08 +0000
committerJohn McCall <rjmccall@apple.com>2009-12-24 11:09:08 +0000
commit9f2df88757c8db3d97fa198f0ad4b6f139baa66a (patch)
tree2b9c76156ca4cc05f9ef63d72c10396d021c4326
parent6675586c70945fdd71911d96f83324788b93edd4 (diff)
Fix the clang-on-clang build: APFloat reports underflow whenever we get a
denormal, but we only want to diagnose if we underflowed to zero. This allows people to write constants in the denormal range. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92129 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaExpr.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 0951677db2..a6b409b99f 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1589,7 +1589,11 @@ Action::OwningExprResult Sema::ActOnNumericConstant(const Token &Tok) {
APFloat Val(Format);
APFloat::opStatus result = Literal.GetFloatValue(Val);
- if (result & (APFloat::opOverflow | APFloat::opUnderflow)) {
+
+ // Overflow is always an error, but underflow is only an error if
+ // we underflowed to zero (APFloat reports denormals as underflow).
+ if ((result & APFloat::opOverflow) ||
+ ((result & APFloat::opUnderflow) && Val.isZero())) {
unsigned diagnostic;
llvm::SmallVector<char, 20> buffer;
if (result & APFloat::opOverflow) {