fixes #14240 [backport:1.2] (#14757)

This commit is contained in:
Andreas Rumpf 2020-06-22 14:11:13 +02:00 • committed by GitHub
commit 451129de42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 9 deletions

View file

@ -688,14 +688,15 @@ proc genBreakStmt(p: BProc, t: PNode) =
proc raiseExit(p: BProc) = proc raiseExit(p: BProc) =
assert p.config.exc == excGoto assert p.config.exc == excGoto
p.flags.incl nimErrorFlagAccessed if nimErrorFlagDisabled notin p.flags:
if p.nestedTryStmts.len == 0: p.flags.incl nimErrorFlagAccessed
p.flags.incl beforeRetNeeded if p.nestedTryStmts.len == 0:
# easy case, simply goto 'ret': p.flags.incl beforeRetNeeded
lineCg(p, cpsStmts, "if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;$n", []) # easy case, simply goto 'ret':
else: lineCg(p, cpsStmts, "if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;$n", [])
lineCg(p, cpsStmts, "if (NIM_UNLIKELY(*nimErr_)) goto LA$1_;$n", else:
[p.nestedTryStmts[^1].label]) lineCg(p, cpsStmts, "if (NIM_UNLIKELY(*nimErr_)) goto LA$1_;$n",
[p.nestedTryStmts[^1].label])
proc finallyActions(p: BProc) = proc finallyActions(p: BProc) =
if p.config.exc != excGoto and p.nestedTryStmts.len > 0 and p.nestedTryStmts[^1].inExcept: if p.config.exc != excGoto and p.nestedTryStmts.len > 0 and p.nestedTryStmts[^1].inExcept:

View file

@ -682,6 +682,7 @@ proc loadDynamicLib(m: BModule, lib: PLib) =
else: else:
var p = newProc(nil, m) var p = newProc(nil, m)
p.options = p.options - {optStackTrace} p.options = p.options - {optStackTrace}
p.flags.incl nimErrorFlagDisabled
var dest: TLoc var dest: TLoc
initLoc(dest, locTemp, lib.path, OnStack) initLoc(dest, locTemp, lib.path, OnStack)
dest.r = getTempName(m) dest.r = getTempName(m)

View file

@ -70,7 +70,8 @@ type
hasCurFramePointer, hasCurFramePointer,
noSafePoints, noSafePoints,
nimErrorFlagAccessed, nimErrorFlagAccessed,
nimErrorFlagDeclared nimErrorFlagDeclared,
nimErrorFlagDisabled
TCProc = object # represents C proc that is currently generated TCProc = object # represents C proc that is currently generated
prc*: PSym # the Nim proc that this C proc belongs to prc*: PSym # the Nim proc that this C proc belongs to