summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorJuan M Gómez <info@jmgomez.me>2023-10-23 07:59:14 +0100
committerGitHub <noreply@github.com>2023-10-23 08:59:14 +0200
commitca577dbab12cb7a9a73ca8d39ce03f568bade2bb (patch)
tree0958e9e1afefe2652fcfcac46d7415ccbf069170 /compiler
parentc13c48500b527cb483480702390b1f230ac896a4 (diff)
downloadNim-ca577dbab12cb7a9a73ca8d39ce03f568bade2bb.tar.gz
C++: ptr fields now pulls the whole type if it's a member in nkDotExpr (#22855)
Diffstat (limited to 'compiler')
-rw-r--r--compiler/ccgexprs.nim6
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim
index eca6fa995..2612c5c12 100644
--- a/compiler/ccgexprs.nim
+++ b/compiler/ccgexprs.nim
@@ -851,6 +851,12 @@ proc lookupFieldAgain(p: BProc, ty: PType; field: PSym; r: var Rope;
 
 proc genRecordField(p: BProc, e: PNode, d: var TLoc) =
   var a: TLoc = default(TLoc)
+  if p.module.compileToCpp and e.kind == nkDotExpr and e[1].kind == nkSym and e[1].typ.kind == tyPtr:
+    # special case for C++: we need to pull the type of the field as member and friends require the complete type.
+    let typ = e[1].typ[0]
+    if typ.itemId in p.module.g.graph.memberProcsPerType:
+      discard getTypeDesc(p.module, typ)
+
   genRecordFieldAux(p, e, d, a)
   var r = rdLoc(a)
   var f = e[1].sym