diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2023-01-28 04:41:59 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-27 21:41:59 +0100 |
commit | 1431f90d8c3d3ed0afcaee62073d5808cea227ff (patch) | |
tree | 0980a960ae6058507a8706d81b8f1e98c8d6e5fb | |
parent | a7bae919adb952362cb53206140872d2b7424b47 (diff) | |
download | Nim-1431f90d8c3d3ed0afcaee62073d5808cea227ff.tar.gz |
Revert "Fix #13093 C++ Atomics: operator= is implicitly deleted because the default definition would be ill-formed " (#21307)
Revert "Fix #13093 C++ Atomics: operator= is implicitly deleted because the default definition would be ill-formed (#21169)" This reverts commit a7bae919adb952362cb53206140872d2b7424b47.
-rw-r--r-- | compiler/cgen.nim | 4 | ||||
-rw-r--r-- | compiler/semstmts.nim | 6 | ||||
-rw-r--r-- | lib/pure/concurrency/atomics.nim | 2 | ||||
-rw-r--r-- | tests/cpp/t13093.nim | 24 | ||||
-rw-r--r-- | tests/cpp/t17982.nim | 20 |
5 files changed, 2 insertions, 54 deletions
diff --git a/compiler/cgen.nim b/compiler/cgen.nim index 869c1bfdd..5bf9400c5 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -491,10 +491,6 @@ 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: diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 12a346f63..c7e48db4c 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -717,11 +717,7 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode = tyUserTypeClassInst}) if actualType.kind in {tyObject, tyDistinct} and actualType.requiresInit: - # 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) + defaultConstructionError(c, v.typ, v.info) else: checkNilable(c, v) # allow let to not be initialised if imported from C: diff --git a/lib/pure/concurrency/atomics.nim b/lib/pure/concurrency/atomics.nim index 49204bd4d..c7b881bc5 100644 --- a/lib/pure/concurrency/atomics.nim +++ b/lib/pure/concurrency/atomics.nim @@ -89,7 +89,7 @@ when defined(cpp) or defined(nimdoc): ## with other moSequentiallyConsistent operations. type - Atomic*[T] {.importcpp: "std::atomic", completeStruct, requiresInit.} = object + Atomic*[T] {.importcpp: "std::atomic", completeStruct.} = object ## An atomic object with underlying type `T`. raw: T diff --git a/tests/cpp/t13093.nim b/tests/cpp/t13093.nim deleted file mode 100644 index 17c730d16..000000000 --- a/tests/cpp/t13093.nim +++ /dev/null @@ -1,24 +0,0 @@ -discard """ - targets: "cpp" - action: reject - errormsg: "The PledgeObj type requires the following fields to be initialized: refCount" -""" - -import atomics - -type - Pledge* = object - p: PledgePtr - - PledgePtr = ptr PledgeObj - PledgeObj = object - refCount: Atomic[int32] - -proc main() = - var pledge: Pledge - pledge.p = createShared(PledgeObj) - let tmp = PledgeObj() # <---- not allowed: atomics are not copyable - - pledge.p[] = tmp - -main() diff --git a/tests/cpp/t17982.nim b/tests/cpp/t17982.nim deleted file mode 100644 index 5413f06ff..000000000 --- a/tests/cpp/t17982.nim +++ /dev/null @@ -1,20 +0,0 @@ -discard """ - targets: "cpp" - action: "compile" -""" - -type - String* {.importcpp: "std::string", header: "string".} = object - -proc initString*(): String - {.importcpp: "std::string()", header: "string".} - -proc append*(this: var String, str: String): String - # bug seems to trigger when `#`, `@`, or `$1` is used inside `importcpp` - {.importcpp: "#.append(@)", header: "string", discardable.} # <- changed from `importcpp: "append"` - -var - s1 = initString() - s2 = initString() - -s1.append s2 |