fixes #4005
This commit is contained in:
parent
0378f9980f
commit
f6e92dcf75
1 changed files with 8 additions and 4 deletions
|
|
@ -672,9 +672,13 @@ proc genDeref(p: BProc, e: PNode, d: var TLoc; enforceDeref=false) =
|
||||||
expr(p, e.sons[0], d)
|
expr(p, e.sons[0], d)
|
||||||
else:
|
else:
|
||||||
var a: TLoc
|
var a: TLoc
|
||||||
initLocExprSingleUse(p, e.sons[0], a)
|
let typ = skipTypes(e.sons[0].typ, abstractInst)
|
||||||
|
if typ.kind == tyVar and tfVarIsPtr notin typ.flags and p.module.compileToCpp and e.sons[0].kind == nkHiddenAddr:
|
||||||
|
initLocExprSingleUse(p, e[0][0], d)
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
initLocExprSingleUse(p, e.sons[0], a)
|
||||||
if d.k == locNone:
|
if d.k == locNone:
|
||||||
let typ = skipTypes(a.t, abstractInst)
|
|
||||||
# dest = *a; <-- We do not know that 'dest' is on the heap!
|
# dest = *a; <-- We do not know that 'dest' is on the heap!
|
||||||
# It is completely wrong to set 'd.s' here, unless it's not yet
|
# It is completely wrong to set 'd.s' here, unless it's not yet
|
||||||
# been assigned to.
|
# been assigned to.
|
||||||
|
|
@ -689,9 +693,9 @@ proc genDeref(p: BProc, e: PNode, d: var TLoc; enforceDeref=false) =
|
||||||
return
|
return
|
||||||
of tyPtr:
|
of tyPtr:
|
||||||
d.s = OnUnknown # BUGFIX!
|
d.s = OnUnknown # BUGFIX!
|
||||||
else: internalError(e.info, "genDeref " & $a.t.kind)
|
else:
|
||||||
|
internalError(e.info, "genDeref " & $typ.kind)
|
||||||
elif p.module.compileToCpp:
|
elif p.module.compileToCpp:
|
||||||
let typ = skipTypes(a.t, abstractInst)
|
|
||||||
if typ.kind == tyVar and tfVarIsPtr notin typ.flags and
|
if typ.kind == tyVar and tfVarIsPtr notin typ.flags and
|
||||||
e.kind == nkHiddenDeref:
|
e.kind == nkHiddenDeref:
|
||||||
putIntoDest(p, d, e.typ, rdLoc(a), a.s)
|
putIntoDest(p, d, e.typ, rdLoc(a), a.s)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue