This commit is contained in:
Andreas Rumpf 2020-03-10 00:52:46 +01:00 • committed by GitHub
commit 090ba1e3a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 4 deletions

View file

@ -1663,6 +1663,11 @@ proc genInitCode(m: BModule) =
if beforeRetNeeded in m.initProc.flags:
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:
prc.add(deinitFrame(m.initProc))
@ -1990,9 +1995,10 @@ proc myClose(graph: ModuleGraph; b: PPassContext, n: PNode): PNode =
if b == nil: return
var m = BModule(b)
if sfMainModule in m.module.flags:
let testForError = getCompilerProc(graph, "nimTestErrorFlag")
if testForError != nil and graph.config.exc == excGoto:
n.add newTree(nkCall, testForError.newSymNode)
# phase ordering problem here: We need to announce this
# dependency to 'nimTestErrorFlag' before system.c has been written to disk.
if m.config.exc == excGoto and getCompilerProc(graph, "nimTestErrorFlag") != nil:
discard cgsym(m, "nimTestErrorFlag")
for i in countdown(high(graph.globalDestructors), 0):
n.add graph.globalDestructors[i]