diff options
author | cooldome <cdome@bk.ru> | 2020-01-20 09:41:12 +0000 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2020-01-20 10:41:12 +0100 |
commit | da1bddb084443f7f386a04c853eb5c1c03b28ce4 (patch) | |
tree | 9e8f6b7266044ed5adacc917ecba3355ad0efa69 /compiler | |
parent | 41555ca86f70771d71e2385629e76db092f0eabb (diff) | |
download | Nim-da1bddb084443f7f386a04c853eb5c1c03b28ce4.tar.gz |
fixes #13195 (#13198)
* fixes #13195 * extra fix * fix typo
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/ccgexprs.nim | 4 | ||||
-rw-r--r-- | compiler/ccgtypes.nim | 5 |
2 files changed, 5 insertions, 4 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index eed29ff4b..fd4556687 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -2818,11 +2818,11 @@ proc getNullValueAux(p: BProc; t: PType; obj, constOrNil: PNode, # 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 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) result.add "}" elif b.kind == nkSym: - result.add "." & lastSon(obj[selectedBranch]).sym.loc.r & " = " + result.add "." & mangleRecFieldName(p.module, b.sym) & " = " getNullValueAux(p, t, b, constOrNil, result, countB, isConst, info) result.add "}" diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index 2bcaa5dc3..905f8999e 100644 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -525,7 +525,8 @@ proc genRecordFieldsAux(m: BModule, n: PNode, of nkOfBranch, nkElse: let k = lastSon(n[i]) 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 tfPacked notin rectype.flags: unionBody.add("struct {") @@ -535,7 +536,7 @@ proc genRecordFieldsAux(m: BModule, n: PNode, else: unionBody.addf("#pragma pack(push, 1)$nstruct{", []) 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: unionBody.addf("#pragma pack(pop)$n", []) else: |