* close #11142 * fix #12636 * undo unwanted changes * fix illegal recursion case
This commit is contained in:
parent
3aab6a409d
commit
3af7818af4
2 changed files with 19 additions and 3 deletions
|
|
@ -258,12 +258,16 @@ proc computeSizeAlign(conf: ConfigRef; typ: PType) =
|
||||||
|
|
||||||
of tyArray:
|
of tyArray:
|
||||||
computeSizeAlign(conf, typ[1])
|
computeSizeAlign(conf, typ[1])
|
||||||
let elemSize = typ[1].size
|
let elemSize = typ[1].size
|
||||||
|
let len = lengthOrd(conf, typ[0])
|
||||||
if elemSize < 0:
|
if elemSize < 0:
|
||||||
typ.size = elemSize
|
typ.size = elemSize
|
||||||
typ.align = int16(elemSize)
|
typ.align = int16(elemSize)
|
||||||
|
elif len < 0:
|
||||||
|
typ.size = szUnknownSize
|
||||||
|
typ.align = szUnknownSize
|
||||||
else:
|
else:
|
||||||
typ.size = toInt64Checked(lengthOrd(conf, typ[0]) * int32(elemSize), szTooBigSize)
|
typ.size = toInt64Checked(len * int32(elemSize), szTooBigSize)
|
||||||
typ.align = typ[1].align
|
typ.align = typ[1].align
|
||||||
|
|
||||||
of tyUncheckedArray:
|
of tyUncheckedArray:
|
||||||
|
|
|
||||||
|
|
@ -361,6 +361,16 @@ testinstance:
|
||||||
y: int32
|
y: int32
|
||||||
z: AnotherEnum
|
z: AnotherEnum
|
||||||
|
|
||||||
|
Stack[N: static int, T: object] = object
|
||||||
|
pad: array[128 - sizeof(array[N, ptr T]) - sizeof(int) - sizeof(pointer), byte]
|
||||||
|
stack: array[N, ptr T]
|
||||||
|
len*: int
|
||||||
|
rawMem: ptr array[N, T]
|
||||||
|
|
||||||
|
Stack2[T: object] = object
|
||||||
|
pad: array[128 - sizeof(array[sizeof(T), ptr T]), byte]
|
||||||
|
|
||||||
|
|
||||||
const trivialSize = sizeof(TrivialType) # needs to be able to evaluate at compile time
|
const trivialSize = sizeof(TrivialType) # needs to be able to evaluate at compile time
|
||||||
|
|
||||||
proc main(): void =
|
proc main(): void =
|
||||||
|
|
@ -377,6 +387,8 @@ testinstance:
|
||||||
var po : PaddingOfSetEnum33
|
var po : PaddingOfSetEnum33
|
||||||
var capo: MyCustomAlignPackedObject
|
var capo: MyCustomAlignPackedObject
|
||||||
var issue15516: MyObject
|
var issue15516: MyObject
|
||||||
|
var issue12636_1: Stack[5, MyObject]
|
||||||
|
var issue12636_2: Stack2[MyObject]
|
||||||
|
|
||||||
var
|
var
|
||||||
e1: Enum1
|
e1: Enum1
|
||||||
|
|
@ -395,7 +407,7 @@ testinstance:
|
||||||
else:
|
else:
|
||||||
doAssert sizeof(SimpleAlignment) > 10
|
doAssert sizeof(SimpleAlignment) > 10
|
||||||
|
|
||||||
testSizeAlignOf(t,a,b,c,d,e,f,g,ro,go,po, e1, e2, e4, e8, eoa, eob, capo, issue15516)
|
testSizeAlignOf(t,a,b,c,d,e,f,g,ro,go,po, e1, e2, e4, e8, eoa, eob, capo, issue15516, issue12636_1, issue12636_2)
|
||||||
|
|
||||||
type
|
type
|
||||||
WithBitsize {.objectconfig.} = object
|
WithBitsize {.objectconfig.} = object
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue