fixes #21632; enforce deref for wasMoved in ORC (#21647)

fixes #21632; enforce deref for `wasMoved`
This commit is contained in:
ringabout
2023-04-12 16:45:45 +08:00
committed by GitHub
parent f05387045d
commit 1ed54b7718
3 changed files with 15 additions and 6 deletions

View File

@@ -2339,7 +2339,7 @@ proc genWasMoved(p: BProc; n: PNode) =
if p.withinBlockLeaveActions > 0 and notYetAlive(n1):
discard
else:
initLocExpr(p, n1, a)
initLocExpr(p, n1, a, {lfEnforceDeref})
resetLoc(p, a)
#linefmt(p, cpsStmts, "#nimZeroMem((void*)$1, sizeof($2));$n",
# [addrLoc(p.config, a), getTypeDesc(p.module, a.t)])

View File

@@ -61,12 +61,12 @@ proc findPendingModule(m: BModule, s: PSym): BModule =
var ms = getModule(s)
result = m.g.modules[ms.position]
proc initLoc(result: var TLoc, k: TLocKind, lode: PNode, s: TStorageLoc) =
proc initLoc(result: var TLoc, k: TLocKind, lode: PNode, s: TStorageLoc, flags: TLocFlags = {}) =
result.k = k
result.storage = s
result.lode = lode
result.r = ""
result.flags = {}
result.flags = flags
proc fillLoc(a: var TLoc, k: TLocKind, lode: PNode, r: Rope, s: TStorageLoc) {.inline.} =
# fills the loc if it is not already initialized
@@ -698,8 +698,8 @@ proc genLiteral(p: BProc, n: PNode; result: var Rope)
proc genOtherArg(p: BProc; ri: PNode; i: int; typ: PType; result: var Rope; argsCounter: var int)
proc raiseExit(p: BProc)
proc initLocExpr(p: BProc, e: PNode, result: var TLoc) =
initLoc(result, locNone, e, OnUnknown)
proc initLocExpr(p: BProc, e: PNode, result: var TLoc, flags: TLocFlags = {}) =
initLoc(result, locNone, e, OnUnknown, flags)
expr(p, e, result)
proc initLocExprSingleUse(p: BProc, e: PNode, result: var TLoc) =

View File

@@ -328,7 +328,16 @@ call()
doAssert program.len == program.rawMatch(grammar, 0, c)
doAssert c.ml == 1
block:
# bug #21632
let p = peg"""
atext <- \w / \d
"""
doAssert "a".match(p)
doAssert "1".match(p)
pegsTest()
static:
pegsTest()