@@ -196,6 +196,11 @@ proc computeUnionObjectOffsetsFoldFunction(conf: ConfigRef; n: PNode; packed: bo
196196 accum.offset = szUnknownSize
197197
198198proc computeSizeAlign (conf: ConfigRef ; typ: PType ) =
199+ template setSize (typ, s) =
200+ typ.size = s
201+ typ.align = s
202+ typ.paddingAtEnd = 0
203+
199204 # # computes and sets ``size`` and ``align`` members of ``typ``
200205 assert typ != nil
201206 let hasSize = typ.size != szUncomputedSize
@@ -258,14 +263,14 @@ proc computeSizeAlign(conf: ConfigRef; typ: PType) =
258263
259264 of tyArray:
260265 computeSizeAlign (conf, typ[1 ])
261- let elemSize = typ[1 ].size
266+ let elemSize = typ[1 ].size
262267 let len = lengthOrd (conf, typ[0 ])
263268 if elemSize < 0 :
264269 typ.size = elemSize
265270 typ.align = int16 (elemSize)
266271 elif len < 0 :
267272 typ.size = szUnknownSize
268- typ.align = szUnknownSize
273+ typ.align = szUnknownSize
269274 else :
270275 typ.size = toInt64Checked (len * int32 (elemSize), szTooBigSize)
271276 typ.align = typ[1 ].align
@@ -445,6 +450,16 @@ proc computeSizeAlign(conf: ConfigRef; typ: PType) =
445450 typ.size = szUnknownSize
446451 typ.align = szUnknownSize
447452 typ.paddingAtEnd = szUnknownSize
453+ of tyInt, tyUInt:
454+ setSize typ, conf.target.intSize.int16
455+ of tyBool, tyChar, tyUInt8, tyInt8:
456+ setSize typ, 1
457+ of tyInt16, tyUInt16:
458+ setSize typ, 2
459+ of tyInt32, tyUInt32:
460+ setSize typ, 4
461+ of tyInt64, tyUInt64:
462+ setSize typ, 8
448463 else :
449464 typ.size = szUnknownSize
450465 typ.align = szUnknownSize
0 commit comments