[cfe-commits] r92129 - /cfe/trunk/lib/Sema/SemaExpr.cpp

John McCall rjmccall at apple.com
Thu Dec 24 03:09:09 PST 2009


Author: rjmccall
Date: Thu Dec 24 05:09:08 2009
New Revision: 92129

URL: http://llvm.org/viewvc/llvm-project?rev=92129&view=rev
Log:
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.


Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=92129&r1=92128&r2=92129&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Dec 24 05:09:08 2009
@@ -1589,7 +1589,11 @@
     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) {





More information about the cfe-commits mailing list