Enable range checking for unsigned integers (#11313)

* Enable range checking for unsigned integers

* Make the tests green
This commit is contained in:
Oscar Nihlgård 2019-05-25 20:48:13 +02:00 • committed by Andreas Rumpf
commit 3a06022071
5 changed files with 24 additions and 7 deletions

View file

@ -1959,9 +1959,7 @@ proc genCast(p: BProc, e: PNode, d: var TLoc) =
proc genRangeChck(p: BProc, n: PNode, d: var TLoc, magic: string) =
var a: TLoc
var dest = skipTypes(n.typ, abstractVar)
# range checks for unsigned turned out to be buggy and annoying:
if optRangeCheck notin p.options or dest.skipTypes({tyRange}).kind in
{tyUInt..tyUInt64}:
if optRangeCheck notin p.options:
initLocExpr(p, n.sons[0], a)
putIntoDest(p, d, n, "(($1) ($2))" %
[getTypeDesc(p.module, dest), rdCharLoc(a)], a.storage)