Skip to content

Commit

Permalink
Fixes #10352 (#10416)
Browse files Browse the repository at this point in the history
  • Loading branch information
slangmgh authored and Araq committed Jan 28, 2019
1 parent 74a7b09 commit dfa5fae
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions compiler/cgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1327,16 +1327,6 @@ proc genInitCode(m: BModule) =
appcg(m, m.s[cfsTypeInit1], "static #TNimType $1[$2];$n",
[m.nimTypesName, rope(m.nimTypes)])

if m.initProc.gcFrameId > 0:
moduleInitRequired = true
add(prc, initGCFrame(m.initProc))

if m.initProc.s(cpsLocals).len > 0:
moduleInitRequired = true
add(prc, genSectionStart(cpsLocals, m.config))
add(prc, m.initProc.s(cpsLocals))
add(prc, genSectionEnd(cpsLocals, m.config))

if m.preInitProc.s(cpsInit).len > 0 or m.preInitProc.s(cpsStmts).len > 0:
# Give this small function its own scope
addf(prc, "{$N", [])
Expand All @@ -1362,6 +1352,19 @@ proc genInitCode(m: BModule) =
add(prc, genSectionEnd(cpsStmts, m.config))
addf(prc, "}$N", [])

# add new scope for following code, because old vcc compiler need variable
# be defined at the top of the block
addf(prc, "{$N", [])
if m.initProc.gcFrameId > 0:
moduleInitRequired = true
add(prc, initGCFrame(m.initProc))

if m.initProc.s(cpsLocals).len > 0:
moduleInitRequired = true
add(prc, genSectionStart(cpsLocals, m.config))
add(prc, m.initProc.s(cpsLocals))
add(prc, genSectionEnd(cpsLocals, m.config))

if m.initProc.s(cpsInit).len > 0 or m.initProc.s(cpsStmts).len > 0:
moduleInitRequired = true
if optStackTrace in m.initProc.options and frameDeclared notin m.flags:
Expand All @@ -1388,6 +1391,7 @@ proc genInitCode(m: BModule) =
if m.initProc.gcFrameId > 0:
moduleInitRequired = true
add(prc, deinitGCFrame(m.initProc))
addf(prc, "}$N", [])

addf(prc, "}$N$N", [])

Expand Down

0 comments on commit dfa5fae

Please sign in to comment.