Fix array address on nkHiddenAddr
This commit is contained in:
parent
ae681be629
commit
7a5a6ec5bc
1 changed files with 5 additions and 4 deletions
|
|
@ -881,14 +881,15 @@ proc genArrayAddr(p: PProc, n: PNode, r: var TCompRes) =
|
|||
a, b: TCompRes
|
||||
first: BiggestInt
|
||||
r.typ = etyBaseIndex
|
||||
gen(p, n.sons[0], a)
|
||||
gen(p, n.sons[1], b)
|
||||
let m = if n.kind == nkHiddenAddr: n.sons[0] else: n
|
||||
gen(p, m.sons[0], a)
|
||||
gen(p, m.sons[1], b)
|
||||
internalAssert a.typ != etyBaseIndex and b.typ != etyBaseIndex
|
||||
r.address = a.res
|
||||
var typ = skipTypes(n.sons[0].typ, abstractPtrs)
|
||||
var typ = skipTypes(m.sons[0].typ, abstractPtrs)
|
||||
if typ.kind in {tyArray, tyArrayConstr}: first = firstOrd(typ.sons[0])
|
||||
else: first = 0
|
||||
if optBoundsCheck in p.options and not isConstExpr(n.sons[1]):
|
||||
if optBoundsCheck in p.options and not isConstExpr(m.sons[1]):
|
||||
useMagic(p, "chckIndx")
|
||||
r.res = ropef("chckIndx($1, $2, $3.length)-$2",
|
||||
[b.res, toRope(first), a.res])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue