From: John McCall Date: Thu, 24 Dec 2009 11:09:08 +0000 (+0000) Subject: Fix the clang-on-clang build: APFloat reports underflow whenever we get a X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9f2df88757c8db3d97fa198f0ad4b6f139baa66a;p=clang 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 --- 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 buffer; if (result & APFloat::opOverflow) {