Bugfix: no #line dir with 0 generated

This commit is contained in:
Araq 2011-06-10 02:22:16 +02:00
commit 5f2d930a54
7 changed files with 15 additions and 16 deletions

View file

@ -17,7 +17,7 @@ proc genLineDir(p: BProc, t: PNode) =
var line = toLinenumber(t.info) # BUGFIX
if line < 0:
line = 0 # negative numbers are not allowed in #line
if optLineDir in p.Options:
if optLineDir in p.Options and line > 0:
appff(p.s[cpsStmts], "#line $2 \"$1\"$n", "; line $2 \"$1\"$n",
[toRope(toFilename(t.info)), toRope(line)])
if ({optStackTrace, optEndb} * p.Options == {optStackTrace, optEndb}) and

View file

@ -62,13 +62,10 @@ proc initTypeTables() =
for i in countup(low(TTypeKind), high(TTypeKind)): InitIdTable(gTypeTable[i])
proc GetUniqueType*(key: PType): PType =
var
t: PType
k: TTypeKind
# this is a hotspot in the compiler!
result = key
if key == nil: return
k = key.kind
var k = key.kind
case k
of tyObject, tyEnum:
result = PType(IdTableGet(gTypeTable[k], key))
@ -84,20 +81,19 @@ proc GetUniqueType*(key: PType): PType =
# to be compared by their structure:
if IdTableHasObjectAsKey(gTypeTable[k], key): return
for h in countup(0, high(gTypeTable[k].data)):
t = PType(gTypeTable[k].data[h].key)
var t = PType(gTypeTable[k].data[h].key)
if (t != nil) and sameType(t, key):
return t
IdTablePut(gTypeTable[k], key, key)
proc TableGetType*(tab: TIdTable, key: PType): PObject =
var t: PType
# returns nil if we need to declare this type
result = IdTableGet(tab, key)
if (result == nil) and (tab.counter > 0):
# we have to do a slow linear search because types may need
# to be compared by their structure:
for h in countup(0, high(tab.data)):
t = PType(tab.data[h].key)
var t = PType(tab.data[h].key)
if t != nil:
if sameType(t, key):
return tab.data[h].val

View file

@ -195,8 +195,7 @@ proc transformVarSection(c: PTransf, v: PNode): PTransNode =
if it.kind == nkCommentStmt:
result[i] = PTransNode(it)
elif it.kind == nkIdentDefs:
if (it.sons[0].kind != nkSym):
InternalError(it.info, "transformVarSection")
if it.sons[0].kind != nkSym: InternalError(it.info, "transformVarSection")
var newVar = copySym(it.sons[0].sym)
incl(newVar.flags, sfFromGeneric)
# fixes a strange bug for rodgen: