diff options
author | Juan M Gómez <info@jmgomez.me> | 2023-07-29 17:05:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-29 18:05:31 +0200 |
commit | e70992d2910e418e3e6d51ae097558ca123e354e (patch) | |
tree | b317085ac376df0b8e7ba4b84410a6e8ff23d46b /tests/cpp | |
parent | f0f3904ff04a46bae6f876b0326162354466f415 (diff) | |
download | Nim-e70992d2910e418e3e6d51ae097558ca123e354e.tar.gz |
fixes an issue where byref wasnt properly handled when using it in a generic param (#22337)
* fixes an issue where byref wasnt properly handled when using it in a generic param * removes unreachable check
Diffstat (limited to 'tests/cpp')
-rw-r--r-- | tests/cpp/tpassbypragmas.nim | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/cpp/tpassbypragmas.nim b/tests/cpp/tpassbypragmas.nim new file mode 100644 index 000000000..f4301656a --- /dev/null +++ b/tests/cpp/tpassbypragmas.nim @@ -0,0 +1,27 @@ +discard """ + targets: "cpp" + cmd: "nim cpp $file" +""" +{.emit:"""/*TYPESECTION*/ + + template<typename T> + struct Box { + T first; + }; + struct Foo { + void test(void (*func)(Box<Foo>& another)){ + + }; + }; +""".} + +type + Foo {.importcpp.} = object + Box[T] {.importcpp:"Box<'0>".} = object + first: T + +proc test(self: Foo, fn: proc(another {.byref.}: Box[Foo]) {.cdecl.}) {.importcpp.} + +proc fn(another {.byref.} : Box[Foo]) {.cdecl.} = discard + +Foo().test(fn) \ No newline at end of file |