Fix #13093 C++ Atomics: operator= is implicitly deleted because the default definition would be ill-formed (#21169)
* add test * fix #17982 Invalid C++ code generation when returning discardable var T * fix #13093 * cpp atomic good example * clearify the condition
This commit is contained in:
parent
7031ea65cd
commit
a7bae919ad
5 changed files with 54 additions and 2 deletions
|
|
@ -491,6 +491,10 @@ proc constructLoc(p: BProc, loc: var TLoc, isTemp = false) =
|
|||
nilLoc.r = rope("NIM_NIL")
|
||||
genRefAssign(p, loc, nilLoc)
|
||||
else:
|
||||
if typ.kind == tyVar:
|
||||
let tt = typ.skipTypes({tyVar})
|
||||
if isImportedType(tt) and tfRequiresInit in tt.flags:
|
||||
return
|
||||
linefmt(p, cpsStmts, "$1 = ($2)0;$n", [rdLoc(loc),
|
||||
getTypeDesc(p.module, typ, mapTypeChooser(loc))])
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -717,7 +717,11 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
|
|||
tyUserTypeClassInst})
|
||||
if actualType.kind in {tyObject, tyDistinct} and
|
||||
actualType.requiresInit:
|
||||
defaultConstructionError(c, v.typ, v.info)
|
||||
# imported type use requiresInit pragma prevent implicit initialization
|
||||
if (tfRequiresInit in actualType.flags and sfImportc in actualType.sym.flags):
|
||||
discard
|
||||
else:
|
||||
defaultConstructionError(c, v.typ, v.info)
|
||||
else:
|
||||
checkNilable(c, v)
|
||||
# allow let to not be initialised if imported from C:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue