fix warnings for deprecated low and high (#15291)
This commit is contained in:
parent
625edf6a98
commit
6a621b35e7
3 changed files with 13 additions and 13 deletions
|
|
@ -1356,8 +1356,8 @@ proc newType*(kind: TTypeKind, owner: PSym): PType =
|
||||||
writeStackTrace()
|
writeStackTrace()
|
||||||
|
|
||||||
proc mergeLoc(a: var TLoc, b: TLoc) =
|
proc mergeLoc(a: var TLoc, b: TLoc) =
|
||||||
if a.k == low(a.k): a.k = b.k
|
if a.k == low(typeof(a.k)): a.k = b.k
|
||||||
if a.storage == low(a.storage): a.storage = b.storage
|
if a.storage == low(typeof(a.storage)): a.storage = b.storage
|
||||||
a.flags.incl b.flags
|
a.flags.incl b.flags
|
||||||
if a.lode == nil: a.lode = b.lode
|
if a.lode == nil: a.lode = b.lode
|
||||||
if a.r == nil: a.r = b.r
|
if a.r == nil: a.r = b.r
|
||||||
|
|
|
||||||
|
|
@ -15,33 +15,33 @@ proc `|+|`*(a, b: BiggestInt): BiggestInt =
|
||||||
if (result xor a) >= 0'i64 or (result xor b) >= 0'i64:
|
if (result xor a) >= 0'i64 or (result xor b) >= 0'i64:
|
||||||
return result
|
return result
|
||||||
if a < 0 or b < 0:
|
if a < 0 or b < 0:
|
||||||
result = low(result)
|
result = low(typeof(result))
|
||||||
else:
|
else:
|
||||||
result = high(result)
|
result = high(typeof(result))
|
||||||
|
|
||||||
proc `|-|`*(a, b: BiggestInt): BiggestInt =
|
proc `|-|`*(a, b: BiggestInt): BiggestInt =
|
||||||
result = a -% b
|
result = a -% b
|
||||||
if (result xor a) >= 0'i64 or (result xor not b) >= 0'i64:
|
if (result xor a) >= 0'i64 or (result xor not b) >= 0'i64:
|
||||||
return result
|
return result
|
||||||
if b > 0:
|
if b > 0:
|
||||||
result = low(result)
|
result = low(typeof(result))
|
||||||
else:
|
else:
|
||||||
result = high(result)
|
result = high(typeof(result))
|
||||||
|
|
||||||
proc `|abs|`*(a: BiggestInt): BiggestInt =
|
proc `|abs|`*(a: BiggestInt): BiggestInt =
|
||||||
if a != low(a):
|
if a != low(typeof(a)):
|
||||||
if a >= 0: result = a
|
if a >= 0: result = a
|
||||||
else: result = -a
|
else: result = -a
|
||||||
else:
|
else:
|
||||||
result = low(a)
|
result = low(typeof(a))
|
||||||
|
|
||||||
proc `|div|`*(a, b: BiggestInt): BiggestInt =
|
proc `|div|`*(a, b: BiggestInt): BiggestInt =
|
||||||
# (0..5) div (0..4) == (0..5) div (1..4) == (0 div 4)..(5 div 1)
|
# (0..5) div (0..4) == (0..5) div (1..4) == (0 div 4)..(5 div 1)
|
||||||
if b == 0'i64:
|
if b == 0'i64:
|
||||||
# make the same as ``div 1``:
|
# make the same as ``div 1``:
|
||||||
result = a
|
result = a
|
||||||
elif a == low(a) and b == -1'i64:
|
elif a == low(typeof(a)) and b == -1'i64:
|
||||||
result = high(result)
|
result = high(typeof(result))
|
||||||
else:
|
else:
|
||||||
result = a div b
|
result = a div b
|
||||||
|
|
||||||
|
|
@ -74,6 +74,6 @@ proc `|*|`*(a, b: BiggestInt): BiggestInt =
|
||||||
return result
|
return result
|
||||||
|
|
||||||
if floatProd >= 0.0:
|
if floatProd >= 0.0:
|
||||||
result = high(result)
|
result = high(typeof(result))
|
||||||
else:
|
else:
|
||||||
result = low(result)
|
result = low(typeof(result))
|
||||||
|
|
|
||||||
|
|
@ -611,7 +611,7 @@ proc genField(c: PCtx; n: PNode): TRegister =
|
||||||
if n.kind != nkSym or n.sym.kind != skField:
|
if n.kind != nkSym or n.sym.kind != skField:
|
||||||
globalError(c.config, n.info, "no field symbol")
|
globalError(c.config, n.info, "no field symbol")
|
||||||
let s = n.sym
|
let s = n.sym
|
||||||
if s.position > high(result):
|
if s.position > high(typeof(result)):
|
||||||
globalError(c.config, n.info,
|
globalError(c.config, n.info,
|
||||||
"too large offset! cannot generate code for: " & s.name.s)
|
"too large offset! cannot generate code for: " & s.name.s)
|
||||||
result = s.position
|
result = s.position
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue