diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2014-06-26 21:04:20 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2014-06-26 21:04:20 +0200 |
commit | 92d1da407a401490a664843322789f502b975131 (patch) | |
tree | b39751f0c3b30281240890d4edfc9a7904adaa75 | |
parent | cb09723033100f2c2a32d0a9a9b12ea824dc26a8 (diff) | |
parent | 912ad820ee1127a595207d2067f0b6eeb0902dca (diff) | |
download | Nim-92d1da407a401490a664843322789f502b975131.tar.gz |
Merge pull request #1278 from Varriount/fix-1090
Fix 1090
-rw-r--r-- | compiler/semstmts.nim | 3 | ||||
-rw-r--r-- | compiler/types.nim | 14 |
2 files changed, 10 insertions, 7 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index d17351988..11399b38b 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -828,6 +828,9 @@ proc typeSectionFinalPass(c: PContext, n: PNode) = getCurrOwner(), s.info) proc semTypeSection(c: PContext, n: PNode): PNode = + ## Processes a type section. This must be done in separate passes, in order + ## to allow the type definitions in the section to reference each other + ## without regard for the order of their definitions. typeSectionLeftSidePass(c, n) typeSectionRightSidePass(c, n) typeSectionFinalPass(c, n) diff --git a/compiler/types.nim b/compiler/types.nim index 1f266d64f..786eea14e 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -1118,6 +1118,11 @@ proc typeAllowed(t: PType, kind: TSymKind): bool = proc align(address, alignment: BiggestInt): BiggestInt = result = (address + (alignment - 1)) and not (alignment - 1) +const + szNonConcreteType* = -3 + szIllegalRecursion* = -2 + szUnknownSize* = -1 + proc computeSizeAux(typ: PType, a: var BiggestInt): BiggestInt proc computeRecSizeAux(n: PNode, a, currOffset: var BiggestInt): BiggestInt = var maxAlign, maxSize, b, res: BiggestInt @@ -1151,14 +1156,9 @@ proc computeRecSizeAux(n: PNode, a, currOffset: var BiggestInt): BiggestInt = of nkSym: result = computeSizeAux(n.sym.typ, a) n.sym.offset = int(currOffset) - else: - internalError("computeRecSizeAux()") + else: a = 1 - result = - 1 - -const - szIllegalRecursion* = -2 - szUnknownSize* = -1 + result = szNonConcreteType proc computeSizeAux(typ: PType, a: var BiggestInt): BiggestInt = var res, maxAlign, length, currOffset: BiggestInt |