diff options
author | Araq <rumpf_a@web.de> | 2011-12-23 00:17:59 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2011-12-23 00:17:59 +0100 |
commit | 69cc24cdf6537d0ecfb9c481ad2fe42a9ce2c744 (patch) | |
tree | 544e1e138d1c286865d9ee9d2a247fbe31f0a60d | |
parent | 4012517d6d98ab0ac263400ef0ecd659a95b76e9 (diff) | |
download | Nim-69cc24cdf6537d0ecfb9c481ad2fe42a9ce2c744.tar.gz |
bugfix: the code gen can now handle alias TLock = TSysLock; this fixes threading bugs
-rwxr-xr-x | compiler/ast.nim | 16 | ||||
-rwxr-xr-x | compiler/lookups.nim | 2 | ||||
-rwxr-xr-x | compiler/pragmas.nim | 3 | ||||
-rwxr-xr-x | compiler/semstmts.nim | 3 | ||||
-rwxr-xr-x | todo.txt | 1 |
5 files changed, 20 insertions, 5 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim index 0b14a0c02..aafd52098 100755 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -772,6 +772,14 @@ proc NewType(kind: TTypeKind, owner: PSym): PType = #if result.id < 2000 then # MessageOut(typeKindToStr[kind] & ' has id: ' & toString(result.id)) +proc mergeLoc(a: var TLoc, b: TLoc) = + if a.k == low(a.k): a.k = b.k + if a.s == low(a.s): a.s = b.s + a.flags = a.flags + b.flags + if a.t == nil: a.t = b.t + if a.r == nil: a.r = b.r + if a.a == 0: a.a = b.a + proc assignType(dest, src: PType) = dest.kind = src.kind dest.flags = src.flags @@ -780,6 +788,14 @@ proc assignType(dest, src: PType) = dest.size = src.size dest.align = src.align dest.containerID = src.containerID + # this fixes 'type TLock = TSysLock': + if src.sym != nil: + if dest.sym != nil: + dest.sym.flags = dest.sym.flags + src.sym.flags + if dest.sym.annex == nil: dest.sym.annex = src.sym.annex + mergeLoc(dest.sym.loc, src.sym.loc) + else: + dest.sym = src.sym newSons(dest, sonsLen(src)) for i in countup(0, sonsLen(src) - 1): dest.sons[i] = src.sons[i] diff --git a/compiler/lookups.nim b/compiler/lookups.nim index 61b8ead4c..ca11896c5 100755 --- a/compiler/lookups.nim +++ b/compiler/lookups.nim @@ -53,7 +53,7 @@ proc CloseScope*(tab: var TSymTab) = var it: TTabIter var s = InitTabIter(it, tab.stack[tab.tos-1]) while s != nil: - if sfForward in s.flags: + if sfForward in s.flags: LocalError(s.info, errImplOfXexpected, getSymRepr(s)) elif {sfUsed, sfExported} * s.flags == {} and optHints in s.options: # BUGFIX: check options in s! diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index a291d4741..9877d4c52 100755 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -147,9 +147,6 @@ proc processMagic(c: PContext, n: PNode, s: PSym) = s.magic = m break if s.magic == mNone: Message(n.info, warnUnknownMagic, v) - # magics don't need an implementation, so we - # treat them as imported, instead of modifing a lot of working code: - incl(s.flags, sfImportc) proc wordToCallConv(sw: TSpecialWord): TCallingConvention = # this assumes that the order of special words and calling conventions is diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 29bf48c19..0317db849 100755 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -733,7 +733,8 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind, n.sons[bodyPos] = ast.emptyNode else: if proto != nil: LocalError(n.info, errImplOfXexpected, proto.name.s) - if {sfImportc, sfBorrow} * s.flags == {}: incl(s.flags, sfForward) + if {sfImportc, sfBorrow} * s.flags == {} and s.magic == mNone: + incl(s.flags, sfForward) elif sfBorrow in s.flags: semBorrow(c, n, s) sideEffectsCheck(c, s) closeScope(c.tab) # close scope for parameters diff --git a/todo.txt b/todo.txt index 35fa001d7..9529e89dc 100755 --- a/todo.txt +++ b/todo.txt @@ -2,6 +2,7 @@ version 0.8.14 ============== - GC should care about interior pointers on the stack +- BUG: absolute paths in compiler generated scripts - BUG: type TX = TTable[string, int] - warning for implicit openArray -> varargs conversion - implement explicit varargs; **but** ``len(varargs)`` problem remains! |