parent
7d07897a99
commit
090ba1e3a3
3 changed files with 21 additions and 4 deletions
|
|
@ -1663,6 +1663,11 @@ proc genInitCode(m: BModule) =
|
||||||
|
|
||||||
if beforeRetNeeded in m.initProc.flags:
|
if beforeRetNeeded in m.initProc.flags:
|
||||||
prc.add(~"\tBeforeRet_: ;$n")
|
prc.add(~"\tBeforeRet_: ;$n")
|
||||||
|
|
||||||
|
if sfMainModule in m.module.flags and m.config.exc == excGoto:
|
||||||
|
if getCompilerProc(m.g.graph, "nimTestErrorFlag") != nil:
|
||||||
|
m.appcg(prc, "\t#nimTestErrorFlag();$n", [])
|
||||||
|
|
||||||
if optStackTrace in m.initProc.options and preventStackTrace notin m.flags:
|
if optStackTrace in m.initProc.options and preventStackTrace notin m.flags:
|
||||||
prc.add(deinitFrame(m.initProc))
|
prc.add(deinitFrame(m.initProc))
|
||||||
|
|
||||||
|
|
@ -1990,9 +1995,10 @@ proc myClose(graph: ModuleGraph; b: PPassContext, n: PNode): PNode =
|
||||||
if b == nil: return
|
if b == nil: return
|
||||||
var m = BModule(b)
|
var m = BModule(b)
|
||||||
if sfMainModule in m.module.flags:
|
if sfMainModule in m.module.flags:
|
||||||
let testForError = getCompilerProc(graph, "nimTestErrorFlag")
|
# phase ordering problem here: We need to announce this
|
||||||
if testForError != nil and graph.config.exc == excGoto:
|
# dependency to 'nimTestErrorFlag' before system.c has been written to disk.
|
||||||
n.add newTree(nkCall, testForError.newSymNode)
|
if m.config.exc == excGoto and getCompilerProc(graph, "nimTestErrorFlag") != nil:
|
||||||
|
discard cgsym(m, "nimTestErrorFlag")
|
||||||
|
|
||||||
for i in countdown(high(graph.globalDestructors), 0):
|
for i in countdown(high(graph.globalDestructors), 0):
|
||||||
n.add graph.globalDestructors[i]
|
n.add graph.globalDestructors[i]
|
||||||
|
|
|
||||||
|
|
@ -591,7 +591,8 @@ proc p(n: PNode; c: var Con; mode: ProcessMode): PNode =
|
||||||
# move the variable declaration to the top of the frame:
|
# move the variable declaration to the top of the frame:
|
||||||
c.addTopVar v
|
c.addTopVar v
|
||||||
# make sure it's destroyed at the end of the proc:
|
# make sure it's destroyed at the end of the proc:
|
||||||
if not isUnpackedTuple(v):
|
if not isUnpackedTuple(v) and sfThread notin v.sym.flags:
|
||||||
|
# do not destroy thread vars for now at all for consistency.
|
||||||
c.destroys.add genDestroy(c, v)
|
c.destroys.add genDestroy(c, v)
|
||||||
elif c.inLoop > 0:
|
elif c.inLoop > 0:
|
||||||
# unpacked tuple needs reset at every loop iteration
|
# unpacked tuple needs reset at every loop iteration
|
||||||
|
|
|
||||||
10
tests/destructor/tgotoexceptions6.nim
Normal file
10
tests/destructor/tgotoexceptions6.nim
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
discard """
|
||||||
|
cmd: "nim c --gc:arc --exceptions:goto $file"
|
||||||
|
outputsub: "Error: unhandled exception: virus detected [ValueError]"
|
||||||
|
exitcode: "1"
|
||||||
|
"""
|
||||||
|
|
||||||
|
# bug #13436
|
||||||
|
proc foo =
|
||||||
|
raise newException(ValueError, "virus detected")
|
||||||
|
foo()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue