diff options
author | Arne Döring <arne.doering@gmx.net> | 2019-01-07 18:09:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-07 18:09:57 +0100 |
commit | abad758a7eff72e9f97224c400e1b48d09ecd97a (patch) | |
tree | 03707e3429fc9e21c656a37b0e95138770a04607 /compiler | |
parent | 387831d657bcbd130b7e739e4d58f7ccc29adae9 (diff) | |
download | Nim-abad758a7eff72e9f97224c400e1b48d09ecd97a.tar.gz |
Fix for sizeof bitsize combination (#10227)
* fix #10082 * added test
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/sizealignoffsetimpl.nim | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/compiler/sizealignoffsetimpl.nim b/compiler/sizealignoffsetimpl.nim index ea4730f57..fb256b895 100644 --- a/compiler/sizealignoffsetimpl.nim +++ b/compiler/sizealignoffsetimpl.nim @@ -154,12 +154,17 @@ proc computePackedObjectOffsetsFoldFunction(conf: ConfigRef; n: PNode, initialOf if result == szIllegalRecursion: break of nkSym: + var size = szUnknownSize if n.sym.bitsize == 0: computeSizeAlign(conf, n.sym.typ) - n.sym.offset = initialOffset.int - result = n.sym.offset + n.sym.typ.size - else: + size = n.sym.typ.size.int + + if initialOffset == szUnknownSize or size == szUnknownSize: + n.sym.offset = szUnknownSize result = szUnknownSize + else: + n.sym.offset = int(initialOffset) + result = initialOffset + n.sym.typ.size else: result = szUnknownSize |