Fixes for ptr array deref codegen (#11191)

* fixes for ptr array derefence codegen
* fix comments, make diff nicer
This commit is contained in:
Jasper Jenkins 2019-05-06 23:14:38 -07:00 • committed by Andreas Rumpf
commit a6ba3116b2
4 changed files with 36 additions and 40 deletions

View file

@ -717,8 +717,10 @@ proc isCppRef(p: BProc; typ: PType): bool {.inline.} =
skipTypes(typ, abstractInstOwned).kind == tyVar and
tfVarIsPtr notin skipTypes(typ, abstractInstOwned).flags
proc genDeref(p: BProc, e: PNode, d: var TLoc; enforceDeref=false) =
let mt = mapType(p.config, e.sons[0].typ)
proc genDeref(p: BProc, e: PNode, d: var TLoc) =
let
enforceDeref = lfEnforceDeref in d.flags
mt = mapType(p.config, e.sons[0].typ)
if mt in {ctArray, ctPtrToArray} and not enforceDeref:
# XXX the amount of hacks for C's arrays is incredible, maybe we should
# simply wrap them in a struct? --> Losing auto vectorization then?
@ -2343,6 +2345,7 @@ proc genTupleConstr(p: BProc, n: PNode, d: var TLoc) =
if it.kind == nkExprColonExpr: it = it.sons[1]
initLoc(rec, locExpr, it, d.storage)
rec.r = "$1.Field$2" % [rdLoc(d), rope(i)]
rec.flags.incl(lfEnforceDeref)
expr(p, it, rec)
proc isConstClosure(n: PNode): bool {.inline.} =