mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-17 05:29:24 +00:00
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
This commit is contained in:
parent
7a8054f5f2
commit
84c744fe58
@ -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!
|
// TODO: Figure out how to test if a double can be cast to a float!
|
||||||
case Type::FloatTyID:
|
case Type::FloatTyID:
|
||||||
|
float FV = float(Val);
|
||||||
|
double DV = double(FV);
|
||||||
|
return IsNAN(Val) || Val == DV;
|
||||||
case Type::DoubleTyID:
|
case Type::DoubleTyID:
|
||||||
return true; // This is the largest type...
|
return true; // This is the largest type...
|
||||||
}
|
}
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
; RUN: llvm-as < %s -o /dev/null -f
|
|
||||||
|
|
||||||
; make sure that 'float' values have their value properly truncated.
|
|
||||||
|
|
||||||
global float 0x1
|
|
@ -1,5 +1,4 @@
|
|||||||
; RUN: llvm-as %s -o /dev/null 2>&1 | grep "constant invalid for type"
|
; RUN: llvm-as %s -o /dev/null 2>&1 | grep "constant invalid for type"
|
||||||
; XFAIL: *
|
|
||||||
|
|
||||||
;; This is a testcase for PR409
|
;; This is a testcase for PR409
|
||||||
|
|
||||||
|
6
test/Verifier/2004-01-22-FloatNormalization.ll
Normal file
6
test/Verifier/2004-01-22-FloatNormalization.ll
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
; RUN: llvm-as < %s -o /dev/null -f
|
||||||
|
; XFAIL: *
|
||||||
|
|
||||||
|
; make sure that invalid 'float' values are caught.
|
||||||
|
|
||||||
|
global float 0x1
|
Loading…
Reference in New Issue
Block a user