fix warnings for deprecated low and high (#15291)

This commit is contained in:
Miran
2020-09-11 01:04:07 +02:00
committed by GitHub
parent 625edf6a98
commit 6a621b35e7
3 changed files with 13 additions and 13 deletions

View File

@@ -1356,8 +1356,8 @@ proc newType*(kind: TTypeKind, owner: PSym): PType =
writeStackTrace()
proc mergeLoc(a: var TLoc, b: TLoc) =
if a.k == low(a.k): a.k = b.k
if a.storage == low(a.storage): a.storage = b.storage
if a.k == low(typeof(a.k)): a.k = b.k
if a.storage == low(typeof(a.storage)): a.storage = b.storage
a.flags.incl b.flags
if a.lode == nil: a.lode = b.lode
if a.r == nil: a.r = b.r

View File

@@ -15,33 +15,33 @@ proc `|+|`*(a, b: BiggestInt): BiggestInt =
if (result xor a) >= 0'i64 or (result xor b) >= 0'i64:
return result
if a < 0 or b < 0:
result = low(result)
result = low(typeof(result))
else:
result = high(result)
result = high(typeof(result))
proc `|-|`*(a, b: BiggestInt): BiggestInt =
result = a -% b
if (result xor a) >= 0'i64 or (result xor not b) >= 0'i64:
return result
if b > 0:
result = low(result)
result = low(typeof(result))
else:
result = high(result)
result = high(typeof(result))
proc `|abs|`*(a: BiggestInt): BiggestInt =
if a != low(a):
if a != low(typeof(a)):
if a >= 0: result = a
else: result = -a
else:
result = low(a)
result = low(typeof(a))
proc `|div|`*(a, b: BiggestInt): BiggestInt =
# (0..5) div (0..4) == (0..5) div (1..4) == (0 div 4)..(5 div 1)
if b == 0'i64:
# make the same as ``div 1``:
result = a
elif a == low(a) and b == -1'i64:
result = high(result)
elif a == low(typeof(a)) and b == -1'i64:
result = high(typeof(result))
else:
result = a div b
@@ -74,6 +74,6 @@ proc `|*|`*(a, b: BiggestInt): BiggestInt =
return result
if floatProd >= 0.0:
result = high(result)
result = high(typeof(result))
else:
result = low(result)
result = low(typeof(result))

View File

@@ -611,7 +611,7 @@ proc genField(c: PCtx; n: PNode): TRegister =
if n.kind != nkSym or n.sym.kind != skField:
globalError(c.config, n.info, "no field symbol")
let s = n.sym
if s.position > high(result):
if s.position > high(typeof(result)):
globalError(c.config, n.info,
"too large offset! cannot generate code for: " & s.name.s)
result = s.position