diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2005-12-22 21:07:29 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2005-12-22 21:07:29 +0000 |
commit | 84c744fe582f05721f9b8a1bef0086184fc5f0ff (patch) | |
tree | a86411eee9b094d30c0767eb5f830742aaa3ad3e /lib/VMCore | |
parent | 7a8054f5f2027bc419d3af2e15c504f2d5fd1dba (diff) | |
download | external_llvm-84c744fe582f05721f9b8a1bef0086184fc5f0ff.zip external_llvm-84c744fe582f05721f9b8a1bef0086184fc5f0ff.tar.gz external_llvm-84c744fe582f05721f9b8a1bef0086184fc5f0ff.tar.bz2 |
Fix PR409:
Implement the suggested check to ensure that out-of-range float constants
don't get accepted by LLVM accidentally. Adjust the supporting test cases
as well.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24963 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/Constants.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 080baf8..c1324b6 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -482,6 +482,9 @@ bool ConstantFP::isValueValidForType(const Type *Ty, double Val) { // TODO: Figure out how to test if a double can be cast to a float! case Type::FloatTyID: + float FV = float(Val); + double DV = double(FV); + return IsNAN(Val) || Val == DV; case Type::DoubleTyID: return true; // This is the largest type... } |