tbug21505.nim 675 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. discard """
  2. action: "compile"
  3. targets: "cpp"
  4. cmd: "nim cpp $file"
  5. """
  6. # see #21505: ensure compilation of imported C++ objects with explicit constructors while retaining default initialization through codegen changes due to #21279
  7. {.emit:"""/*TYPESECTION*/
  8. struct ExplObj
  9. {
  10. explicit ExplObj(int bar = 0) {}
  11. };
  12. struct BareObj
  13. {
  14. BareObj() {}
  15. };
  16. """.}
  17. type
  18. ExplObj {.importcpp.} = object
  19. BareObj {.importcpp.} = object
  20. type
  21. Composer = object
  22. explObj: ExplObj
  23. bareObj: BareObj
  24. proc foo =
  25. var composer1 {.used.}: Composer
  26. let composer2 {.used.} = Composer()
  27. var composer1 {.used.}: Composer
  28. let composer2 {.used.} = Composer()
  29. foo()