mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-01 19:02:18 +00:00
fixes #5140
This commit is contained in:
@@ -207,7 +207,9 @@ proc isImportedType(t: PType): bool =
|
||||
result = t.sym != nil and sfImportc in t.sym.flags
|
||||
|
||||
proc isImportedCppType(t: PType): bool =
|
||||
result = t.sym != nil and sfInfixCall in t.sym.flags
|
||||
let x = t.skipTypes(irrelevantForBackend)
|
||||
result = (t.sym != nil and sfInfixCall in t.sym.flags) or
|
||||
(x.sym != nil and sfInfixCall in x.sym.flags)
|
||||
|
||||
proc getTypeDescAux(m: BModule, origTyp: PType, check: var IntSet): Rope
|
||||
proc needsComplexAssignment(typ: PType): bool =
|
||||
|
||||
28
tests/cpp/tdont_init_instantiation.nim
Normal file
28
tests/cpp/tdont_init_instantiation.nim
Normal file
@@ -0,0 +1,28 @@
|
||||
discard """
|
||||
cmd: "nim cpp $file"
|
||||
output: ''''''
|
||||
"""
|
||||
|
||||
# bug #5140
|
||||
{.emit:"""
|
||||
#import <cassert>
|
||||
|
||||
template <typename X> class C {
|
||||
public:
|
||||
int d;
|
||||
|
||||
C(): d(1) { }
|
||||
|
||||
C<X>& operator=(const C<X> other) {
|
||||
assert(d == 1);
|
||||
}
|
||||
};
|
||||
""".}
|
||||
|
||||
type C{.importcpp, header: "<stdio.h>", nodecl.} [X] = object
|
||||
proc mkC[X]: C[X] {.importcpp: "C<'*0>()", constructor, nodecl.}
|
||||
|
||||
proc foo(): C[int] =
|
||||
result = mkC[int]()
|
||||
|
||||
discard foo()
|
||||
Reference in New Issue
Block a user