parent
a577a88c36
commit
8aadba1a2a
2 changed files with 23 additions and 9 deletions
|
|
@ -698,19 +698,21 @@ proc raiseExit(p: BProc) =
|
||||||
lineCg(p, cpsStmts, "if (NIM_UNLIKELY(*nimErr_)) goto LA$1_;$n",
|
lineCg(p, cpsStmts, "if (NIM_UNLIKELY(*nimErr_)) goto LA$1_;$n",
|
||||||
[p.nestedTryStmts[^1].label])
|
[p.nestedTryStmts[^1].label])
|
||||||
|
|
||||||
|
proc finallyActions(p: BProc) =
|
||||||
|
if p.config.exc != excGoto and p.nestedTryStmts.len > 0 and p.nestedTryStmts[^1].inExcept:
|
||||||
|
# if the current try stmt have a finally block,
|
||||||
|
# we must execute it before reraising
|
||||||
|
let finallyBlock = p.nestedTryStmts[^1].fin
|
||||||
|
if finallyBlock != nil:
|
||||||
|
genSimpleBlock(p, finallyBlock[0])
|
||||||
|
|
||||||
proc genRaiseStmt(p: BProc, t: PNode) =
|
proc genRaiseStmt(p: BProc, t: PNode) =
|
||||||
if p.config.exc != excGoto:
|
if p.config.exc == excCpp:
|
||||||
if p.config.exc == excCpp:
|
discard cgsym(p.module, "popCurrentExceptionEx")
|
||||||
discard cgsym(p.module, "popCurrentExceptionEx")
|
|
||||||
if p.nestedTryStmts.len > 0 and p.nestedTryStmts[^1].inExcept:
|
|
||||||
# if the current try stmt have a finally block,
|
|
||||||
# we must execute it before reraising
|
|
||||||
let finallyBlock = p.nestedTryStmts[^1].fin
|
|
||||||
if finallyBlock != nil:
|
|
||||||
genSimpleBlock(p, finallyBlock[0])
|
|
||||||
if t[0].kind != nkEmpty:
|
if t[0].kind != nkEmpty:
|
||||||
var a: TLoc
|
var a: TLoc
|
||||||
initLocExprSingleUse(p, t[0], a)
|
initLocExprSingleUse(p, t[0], a)
|
||||||
|
finallyActions(p)
|
||||||
var e = rdLoc(a)
|
var e = rdLoc(a)
|
||||||
var typ = skipTypes(t[0].typ, abstractPtrs)
|
var typ = skipTypes(t[0].typ, abstractPtrs)
|
||||||
genLineDir(p, t)
|
genLineDir(p, t)
|
||||||
|
|
@ -724,6 +726,7 @@ proc genRaiseStmt(p: BProc, t: PNode) =
|
||||||
if optOwnedRefs in p.config.globalOptions:
|
if optOwnedRefs in p.config.globalOptions:
|
||||||
lineCg(p, cpsStmts, "$1 = NIM_NIL;$n", [e])
|
lineCg(p, cpsStmts, "$1 = NIM_NIL;$n", [e])
|
||||||
else:
|
else:
|
||||||
|
finallyActions(p)
|
||||||
genLineDir(p, t)
|
genLineDir(p, t)
|
||||||
# reraise the last exception:
|
# reraise the last exception:
|
||||||
if p.config.exc == excCpp:
|
if p.config.exc == excCpp:
|
||||||
|
|
|
||||||
11
tests/destructor/tsetjmp_raise.nim
Normal file
11
tests/destructor/tsetjmp_raise.nim
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
discard """
|
||||||
|
outputsub: "index 2 not in 0 .. 0 [IndexError]"
|
||||||
|
exitcode: 1
|
||||||
|
cmd: "nim c --gc:arc --exceptions:setjmp $file"
|
||||||
|
"""
|
||||||
|
|
||||||
|
# bug #12961
|
||||||
|
# --gc:arc --exceptions:setjmp
|
||||||
|
let a = @[1]
|
||||||
|
echo a[2]
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue