hotfix for 32bit unsigned 'range' checking; incomplete, unknown why some operations produce range checks
This commit is contained in:
parent
c644bf399f
commit
84ca1f3bf3
2 changed files with 8 additions and 1 deletions
|
|
@ -1967,11 +1967,12 @@ proc genRangeChck(p: BProc, n: PNode, d: var TLoc, magic: string) =
|
||||||
putIntoDest(p, d, n, "(($1) ($2))" %
|
putIntoDest(p, d, n, "(($1) ($2))" %
|
||||||
[getTypeDesc(p.module, dest), rdCharLoc(a)], a.storage)
|
[getTypeDesc(p.module, dest), rdCharLoc(a)], a.storage)
|
||||||
else:
|
else:
|
||||||
|
let mm = if dest.kind in {tyUInt32, tyUInt64, tyUInt}: "chckRangeU" else: magic
|
||||||
initLocExpr(p, n.sons[0], a)
|
initLocExpr(p, n.sons[0], a)
|
||||||
putIntoDest(p, d, lodeTyp dest, ropecg(p.module, "(($1)#$5($2, $3, $4))", [
|
putIntoDest(p, d, lodeTyp dest, ropecg(p.module, "(($1)#$5($2, $3, $4))", [
|
||||||
getTypeDesc(p.module, dest), rdCharLoc(a),
|
getTypeDesc(p.module, dest), rdCharLoc(a),
|
||||||
genLiteral(p, n.sons[1], dest), genLiteral(p, n.sons[2], dest),
|
genLiteral(p, n.sons[1], dest), genLiteral(p, n.sons[2], dest),
|
||||||
magic]), a.storage)
|
mm]), a.storage)
|
||||||
|
|
||||||
proc genConv(p: BProc, e: PNode, d: var TLoc) =
|
proc genConv(p: BProc, e: PNode, d: var TLoc) =
|
||||||
let destType = e.typ.skipTypes({tyVar, tyLent, tyGenericInst, tyAlias, tySink})
|
let destType = e.typ.skipTypes({tyVar, tyLent, tyGenericInst, tyAlias, tySink})
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,12 @@ proc chckRange64(i, a, b: int64): int64 {.compilerproc.} =
|
||||||
else:
|
else:
|
||||||
raiseRangeError(i)
|
raiseRangeError(i)
|
||||||
|
|
||||||
|
proc chckRangeU(i, a, b: uint64): uint64 {.compilerproc.} =
|
||||||
|
if i >= a and i <= b:
|
||||||
|
return i
|
||||||
|
else:
|
||||||
|
sysFatal(RangeError, "value out of range")
|
||||||
|
|
||||||
proc chckRangeF(x, a, b: float): float =
|
proc chckRangeF(x, a, b: float): float =
|
||||||
if x >= a and x <= b:
|
if x >= a and x <= b:
|
||||||
return x
|
return x
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue