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:
Bung 2023-01-27 00:50:44 -08:00 • committed by GitHub
commit a7bae919ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 2 deletions

View file

@ -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: