mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-21 06:45:27 +00:00
fixes #5549
This commit is contained in:
@@ -444,20 +444,21 @@ proc assignGlobalVar(p: BProc, n: PNode) =
|
||||
return
|
||||
useHeader(p.module, s)
|
||||
if lfNoDecl in s.loc.flags: return
|
||||
if sfThread in s.flags:
|
||||
declareThreadVar(p.module, s, sfImportc in s.flags)
|
||||
else:
|
||||
var decl: Rope = nil
|
||||
var td = getTypeDesc(p.module, s.loc.t)
|
||||
if s.constraint.isNil:
|
||||
if sfImportc in s.flags: add(decl, "extern ")
|
||||
add(decl, td)
|
||||
if sfRegister in s.flags: add(decl, " register")
|
||||
if sfVolatile in s.flags: add(decl, " volatile")
|
||||
addf(decl, " $1;$n", [s.loc.r])
|
||||
if not containsOrIncl(p.module.declaredThings, s.id):
|
||||
if sfThread in s.flags:
|
||||
declareThreadVar(p.module, s, sfImportc in s.flags)
|
||||
else:
|
||||
decl = (s.cgDeclFrmt & ";$n") % [td, s.loc.r]
|
||||
add(p.module.s[cfsVars], decl)
|
||||
var decl: Rope = nil
|
||||
var td = getTypeDesc(p.module, s.loc.t)
|
||||
if s.constraint.isNil:
|
||||
if sfImportc in s.flags: add(decl, "extern ")
|
||||
add(decl, td)
|
||||
if sfRegister in s.flags: add(decl, " register")
|
||||
if sfVolatile in s.flags: add(decl, " volatile")
|
||||
addf(decl, " $1;$n", [s.loc.r])
|
||||
else:
|
||||
decl = (s.cgDeclFrmt & ";$n") % [td, s.loc.r]
|
||||
add(p.module.s[cfsVars], decl)
|
||||
if p.withinLoop > 0:
|
||||
# fixes tests/run/tzeroarray:
|
||||
resetLoc(p, s.loc)
|
||||
@@ -1036,7 +1037,7 @@ proc genVarPrototype(m: BModule, n: PNode) =
|
||||
let sym = n.sym
|
||||
useHeader(m, sym)
|
||||
fillLoc(sym.loc, locGlobalVar, n, mangleName(m, sym), OnHeap)
|
||||
if (lfNoDecl in sym.loc.flags) or containsOrIncl(m.declaredThings, sym.id):
|
||||
if (lfNoDecl in sym.loc.flags) or contains(m.declaredThings, sym.id):
|
||||
return
|
||||
if sym.owner.id != m.module.id:
|
||||
# else we already have the symbol generated!
|
||||
@@ -1055,7 +1056,7 @@ proc addIntTypes(result: var Rope; conf: ConfigRef) {.inline.} =
|
||||
addf(result, "#define NIM_NEW_MANGLING_RULES\L" &
|
||||
"#define NIM_INTBITS $1\L", [
|
||||
platform.CPU[conf.target.targetCPU].intSize.rope])
|
||||
if conf.cppCustomNamespace.len > 0:
|
||||
if conf.cppCustomNamespace.len > 0:
|
||||
result.add("#define USE_NIM_NAMESPACE ")
|
||||
result.add(conf.cppCustomNamespace)
|
||||
result.add("\L")
|
||||
|
||||
@@ -35,3 +35,13 @@ try:
|
||||
except:
|
||||
echo "caught"
|
||||
|
||||
|
||||
# issue 5549
|
||||
|
||||
var strs: seq[string] = @[]
|
||||
|
||||
try:
|
||||
discard
|
||||
finally:
|
||||
for foobar in strs:
|
||||
discard
|
||||
|
||||
Reference in New Issue
Block a user