summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2005-12-22 21:07:29 +0000
committerReid Spencer <rspencer@reidspencer.com>2005-12-22 21:07:29 +0000
commit8f8124edaa822d8ddf19aa3ad3455bd5737487b7 (patch)
tree3131ed0c0895327b1941afdd9ead870f40b82e5b /llvm/lib
parentd834d495b2e886169967dee509ecb860ee1fd236 (diff)
downloadbcm5719-llvm-8f8124edaa822d8ddf19aa3ad3455bd5737487b7.tar.gz
bcm5719-llvm-8f8124edaa822d8ddf19aa3ad3455bd5737487b7.zip
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. llvm-svn: 24963
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/VMCore/Constants.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp
index 080baf8d63b..c1324b6b265 100644
--- a/llvm/lib/VMCore/Constants.cpp
+++ b/llvm/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...
}
OpenPOWER on IntegriCloud