summary refs log tree commit diff stats
path: root/tests/ccgbugs/t13062.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ccgbugs/t13062.nim')
-rw-r--r--tests/ccgbugs/t13062.nim33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/ccgbugs/t13062.nim b/tests/ccgbugs/t13062.nim
new file mode 100644
index 000000000..cfda1da7c
--- /dev/null
+++ b/tests/ccgbugs/t13062.nim
@@ -0,0 +1,33 @@
+discard """
+  matrix: "--mm:refc; --mm:orc"
+  targets: "c cpp"
+"""
+
+import atomics
+
+type
+  Pledge* {.exportc.} = object
+    p: PledgePtr
+
+  PledgeKind {.exportc.} = enum
+    Single
+    Iteration
+
+  PledgePtr {.exportc.} = ptr object
+    case kind: PledgeKind
+    of Single:
+      impl: PledgeImpl
+    of Iteration:
+      discard
+
+  PledgeImpl {.exportc.} = object
+    fulfilled: Atomic[bool]
+
+var x: Pledge
+when defined(cpp):
+  # TODO: fixme
+  discard "it doesn't work for refc/orc because of contrived `Atomic` in cpp"
+elif defined(gcRefc):
+  doAssert x.repr == "[p = nil]"
+else: # fixme # bug #20081
+  doAssert x.repr == "Pledge(p: nil)"