mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-17 21:12:42 +00:00
Restore compatibility with old vcc versions [backport] (#10415)
Local variables are declared before anything else. Fixes #10352
This commit is contained in:
@@ -1313,9 +1313,19 @@ proc genInitCode(m: BModule) =
|
||||
appcg(m, m.s[cfsTypeInit1], "static #TNimType $1[$2];$n",
|
||||
[m.nimTypesName, rope(m.nimTypes)])
|
||||
|
||||
# Give this small function its own scope
|
||||
addf(prc, "{$N", [])
|
||||
block:
|
||||
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", [])
|
||||
# Keep a bogus frame in case the code needs one
|
||||
add(prc, ~"\tTFrame FR_; FR_.len = 0;$N")
|
||||
|
||||
@@ -1336,17 +1346,7 @@ proc genInitCode(m: BModule) =
|
||||
add(prc, genSectionStart(cpsStmts, m.config))
|
||||
add(prc, m.preInitProc.s(cpsStmts))
|
||||
add(prc, genSectionEnd(cpsStmts, m.config))
|
||||
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))
|
||||
addf(prc, "}$N", [])
|
||||
|
||||
if m.initProc.s(cpsInit).len > 0 or m.initProc.s(cpsStmts).len > 0:
|
||||
moduleInitRequired = true
|
||||
|
||||
Reference in New Issue
Block a user