Skip to content

Commit

Permalink
fixes #14240 [backport:1.2] (#14757)
Browse files Browse the repository at this point in the history
  • Loading branch information
Araq committed Jun 22, 2020
1 parent 8df2027 commit 451129d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
17 changes: 9 additions & 8 deletions compiler/ccgstmts.nim
Expand Up @@ -688,14 +688,15 @@ proc genBreakStmt(p: BProc, t: PNode) =

proc raiseExit(p: BProc) =
assert p.config.exc == excGoto
p.flags.incl nimErrorFlagAccessed
if p.nestedTryStmts.len == 0:
p.flags.incl beforeRetNeeded
# easy case, simply goto 'ret':
lineCg(p, cpsStmts, "if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;$n", [])
else:
lineCg(p, cpsStmts, "if (NIM_UNLIKELY(*nimErr_)) goto LA$1_;$n",
[p.nestedTryStmts[^1].label])
if nimErrorFlagDisabled notin p.flags:
p.flags.incl nimErrorFlagAccessed
if p.nestedTryStmts.len == 0:
p.flags.incl beforeRetNeeded
# easy case, simply goto 'ret':
lineCg(p, cpsStmts, "if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;$n", [])
else:
lineCg(p, cpsStmts, "if (NIM_UNLIKELY(*nimErr_)) goto LA$1_;$n",
[p.nestedTryStmts[^1].label])

proc finallyActions(p: BProc) =
if p.config.exc != excGoto and p.nestedTryStmts.len > 0 and p.nestedTryStmts[^1].inExcept:
Expand Down
1 change: 1 addition & 0 deletions compiler/cgen.nim
Expand Up @@ -682,6 +682,7 @@ proc loadDynamicLib(m: BModule, lib: PLib) =
else:
var p = newProc(nil, m)
p.options = p.options - {optStackTrace}
p.flags.incl nimErrorFlagDisabled
var dest: TLoc
initLoc(dest, locTemp, lib.path, OnStack)
dest.r = getTempName(m)
Expand Down
3 changes: 2 additions & 1 deletion compiler/cgendata.nim
Expand Up @@ -70,7 +70,8 @@ type
hasCurFramePointer,
noSafePoints,
nimErrorFlagAccessed,
nimErrorFlagDeclared
nimErrorFlagDeclared,
nimErrorFlagDisabled

TCProc = object # represents C proc that is currently generated
prc*: PSym # the Nim proc that this C proc belongs to
Expand Down

0 comments on commit 451129d

Please sign in to comment.