mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-27 09:43:58 +00:00
partially fixes #20787 by having a char dummy member prepended to objs only containing an UncheckedArray (i.e. C FAM) (#21979)
partial fix for #20787
This commit is contained in:
@@ -774,8 +774,15 @@ proc getRecordDesc(m: BModule; typ: PType, name: Rope,
|
||||
result = structOrUnion & " " & name
|
||||
result.add(getRecordDescAux(m, typ, name, baseType, check, hasField))
|
||||
let desc = getRecordFields(m, typ, check)
|
||||
if desc == "" and not hasField:
|
||||
result.addf("char dummy;$n", [])
|
||||
if not hasField:
|
||||
if desc == "":
|
||||
result.add("\tchar dummy;\n")
|
||||
elif typ.len == 1 and typ.n[0].kind == nkSym:
|
||||
let field = typ.n[0].sym
|
||||
let fieldType = field.typ.skipTypes(abstractInst)
|
||||
if fieldType.kind == tyUncheckedArray:
|
||||
result.add("\tchar dummy;\n")
|
||||
result.add(desc)
|
||||
else:
|
||||
result.add(desc)
|
||||
result.add("};\L")
|
||||
|
||||
4
tests/ccgbugs/t20787.nim
Normal file
4
tests/ccgbugs/t20787.nim
Normal file
@@ -0,0 +1,4 @@
|
||||
type
|
||||
Obj = object
|
||||
f: UncheckedArray[byte]
|
||||
let o = new Obj
|
||||
Reference in New Issue
Block a user