]> granicus.if.org Git - clang/commitdiff
Fix the clang-on-clang build: APFloat reports underflow whenever we get a
authorJohn McCall <rjmccall@apple.com>
Thu, 24 Dec 2009 11:09:08 +0000 (11:09 +0000)
committerJohn McCall <rjmccall@apple.com>
Thu, 24 Dec 2009 11:09:08 +0000 (11:09 +0000)
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

lib/Sema/SemaExpr.cpp

index 0951677db240c676697a2034d3f52a6216d4780f..a6b409b99face8db11281626e7196d0810ab7a8c 100644 (file)
@@ -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) {