fixes #13195
This commit is contained in:
parent
13ddbc46fc
commit
cd7904f2b2
3 changed files with 29 additions and 4 deletions
|
|
@ -2818,11 +2818,10 @@ proc getNullValueAux(p: BProc; t: PType; obj, constOrNil: PNode,
|
||||||
# designated initilization is the only way to init non first element of unions
|
# designated initilization is the only way to init non first element of unions
|
||||||
# branches are allowed to have no members (b.len == 0), in this case they don't need initializer
|
# branches are allowed to have no members (b.len == 0), in this case they don't need initializer
|
||||||
if b.kind == nkRecList and b.len > 0:
|
if b.kind == nkRecList and b.len > 0:
|
||||||
result.add "._i" & $selectedBranch & " = {"
|
result.add "._" & mangleRecFieldName(p.module, obj[0].sym) & "_" & $selectedBranch & " = {"
|
||||||
getNullValueAux(p, t, b, constOrNil, result, countB, isConst, info)
|
getNullValueAux(p, t, b, constOrNil, result, countB, isConst, info)
|
||||||
result.add "}"
|
result.add "}"
|
||||||
elif b.kind == nkSym:
|
elif b.kind == nkSym:
|
||||||
result.add "." & lastSon(obj[selectedBranch]).sym.loc.r & " = "
|
|
||||||
getNullValueAux(p, t, b, constOrNil, result, countB, isConst, info)
|
getNullValueAux(p, t, b, constOrNil, result, countB, isConst, info)
|
||||||
result.add "}"
|
result.add "}"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -525,7 +525,8 @@ proc genRecordFieldsAux(m: BModule, n: PNode,
|
||||||
of nkOfBranch, nkElse:
|
of nkOfBranch, nkElse:
|
||||||
let k = lastSon(n[i])
|
let k = lastSon(n[i])
|
||||||
if k.kind != nkSym:
|
if k.kind != nkSym:
|
||||||
let a = genRecordFieldsAux(m, k, rectype, check, unionPrefix & "_i" & $i & ".")
|
let structName = "_" & mangleRecFieldName(m, n[0].sym) & "_" & $i
|
||||||
|
let a = genRecordFieldsAux(m, k, rectype, check, unionPrefix & $structName & ".")
|
||||||
if a != nil:
|
if a != nil:
|
||||||
if tfPacked notin rectype.flags:
|
if tfPacked notin rectype.flags:
|
||||||
unionBody.add("struct {")
|
unionBody.add("struct {")
|
||||||
|
|
@ -535,7 +536,7 @@ proc genRecordFieldsAux(m: BModule, n: PNode,
|
||||||
else:
|
else:
|
||||||
unionBody.addf("#pragma pack(push, 1)$nstruct{", [])
|
unionBody.addf("#pragma pack(push, 1)$nstruct{", [])
|
||||||
unionBody.add(a)
|
unionBody.add(a)
|
||||||
unionBody.addf("} _i$1;$n", [rope($i)])
|
unionBody.addf("} $1;$n", [structName])
|
||||||
if tfPacked in rectype.flags and hasAttribute notin CC[m.config.cCompiler].props:
|
if tfPacked in rectype.flags and hasAttribute notin CC[m.config.cCompiler].props:
|
||||||
unionBody.addf("#pragma pack(pop)$n", [])
|
unionBody.addf("#pragma pack(pop)$n", [])
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,30 @@ type
|
||||||
of tkInt64, tkComma..tkString: ff: seq[float]
|
of tkInt64, tkComma..tkString: ff: seq[float]
|
||||||
else: str1*: string
|
else: str1*: string
|
||||||
|
|
||||||
|
Token4* = object
|
||||||
|
case kind*: TokenKind
|
||||||
|
of tkNumber: numVal*: float
|
||||||
|
of tkInt64, tkComma..tkString: ff: seq[float]
|
||||||
|
else: str1*: string
|
||||||
|
case kind2*: TokenKind
|
||||||
|
of tkNumber:
|
||||||
|
numVal2*: float
|
||||||
|
intSeqVal3*: seq[int]
|
||||||
|
of tkInt64, tkComma..tkString:
|
||||||
|
case kind3*: TokenKind
|
||||||
|
of tkNumber: numVal3*: float
|
||||||
|
of tkInt64, tkComma..tkString:
|
||||||
|
ff3: seq[float]
|
||||||
|
ff5: string
|
||||||
|
else:
|
||||||
|
str3*: string
|
||||||
|
mysrq: seq[int]
|
||||||
|
else:
|
||||||
|
case kind4*: TokenKind
|
||||||
|
of tkNumber: numVal4*: float
|
||||||
|
of tkInt64, tkComma..tkString: ff4: seq[float]
|
||||||
|
else: str4*: string
|
||||||
|
|
||||||
BaseLexer* = object of RootObj
|
BaseLexer* = object of RootObj
|
||||||
input*: string
|
input*: string
|
||||||
pos*: Natural
|
pos*: Natural
|
||||||
|
|
@ -58,6 +82,7 @@ type
|
||||||
tok: Token
|
tok: Token
|
||||||
tok2: Token2
|
tok2: Token2
|
||||||
tok3: Token3
|
tok3: Token3
|
||||||
|
tok4: Token4
|
||||||
allowTrailingComma: bool
|
allowTrailingComma: bool
|
||||||
allowIdentifierObjectKey: bool
|
allowIdentifierObjectKey: bool
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue