diff options
author | heterodoxic <122719743+heterodoxic@users.noreply.github.com> | 2023-03-27 17:20:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-27 17:20:20 +0200 |
commit | 7d83dfd0d1a416cdf36a23b61c87a1ad2c234909 (patch) | |
tree | 0cca200920b3e9c0639bf8de1dad293de804983b /tests/ccgbugs/tbug21505.nim | |
parent | 3936071772d648f98c36e5aad16a341b86344e6c (diff) | |
download | Nim-7d83dfd0d1a416cdf36a23b61c87a1ad2c234909.tar.gz |
fixes #21505 (overload resolution of explicit constructors for imported C++ types) (#21511)
hacky attempt to reconcile default explicit constructors with enforcement of brace initialization, instead of memsetting imported objects to 0
Diffstat (limited to 'tests/ccgbugs/tbug21505.nim')
-rw-r--r-- | tests/ccgbugs/tbug21505.nim | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/ccgbugs/tbug21505.nim b/tests/ccgbugs/tbug21505.nim new file mode 100644 index 000000000..0c0811ec5 --- /dev/null +++ b/tests/ccgbugs/tbug21505.nim @@ -0,0 +1,39 @@ +discard """ + action: "compile" + targets: "cpp" + cmd: "nim cpp $file" +""" + +# see #21505: ensure compilation of imported C++ objects with explicit constructors while retaining default initialization through codegen changes due to #21279 + +{.emit:"""/*TYPESECTION*/ + +struct ExplObj +{ + explicit ExplObj(int bar = 0) {} +}; + +struct BareObj +{ + BareObj() {} +}; + +""".} + +type + ExplObj {.importcpp.} = object + BareObj {.importcpp.} = object + +type + Composer = object + explObj: ExplObj + bareObj: BareObj + +proc foo = + var composer1 {.used.}: Composer + let composer2 {.used.} = Composer() + +var composer1 {.used.}: Composer +let composer2 {.used.} = Composer() + +foo() \ No newline at end of file |