gc:destructors: add first test program

This commit is contained in:
Andreas Rumpf 2019-02-19 23:32:41 +01:00
commit 7e404c670d
2 changed files with 20 additions and 1 deletions

View file

@ -316,7 +316,9 @@ proc resetLoc(p: BProc, loc: var TLoc) =
let containsGcRef = containsGarbageCollectedRef(loc.t)
let typ = skipTypes(loc.t, abstractVarRange)
if isImportedCppType(typ): return
if not isComplexValueType(typ):
if p.config.selectedGc == gcDestructors and typ.kind in {tyString, tySequence}:
linefmt(p, cpsStmts, "$1.len = 0; $1.p = NIM_NIL;$n", rdLoc(loc))
elif not isComplexValueType(typ):
if containsGcRef:
var nilLoc: TLoc
initLoc(nilLoc, locTemp, loc.lode, OnStack)