From 4fd900f3d5bfe2a686e3f4d7a7a5b68f3a2318cd Mon Sep 17 00:00:00 2001 From: Araq Date: Mon, 20 May 2013 12:33:07 +0200 Subject: [PATCH] attempt to fix a codegen bug --- compiler/ccgexprs.nim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 410e65ac90..a5c4a8de7a 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -604,7 +604,13 @@ proc genDeref(p: BProc, e: PNode, d: var TLoc) = putIntoDest(p, d, a.t.sons[0], ropef("(*$1)", [rdLoc(a)])) proc genAddr(p: BProc, e: PNode, d: var TLoc) = - if mapType(e.sons[0].typ) == ctArray: + # careful 'addr(myptrToArray)' needs to get the ampersand: + if e.sons[0].typ.skipTypes(abstractInst).kind in {tyRef, tyPtr}: + var a: TLoc + InitLocExpr(p, e.sons[0], a) + putIntoDest(p, d, e.typ, con("&", a.r)) + #Message(e.info, warnUser, "HERE NEW &") + elif mapType(e.sons[0].typ) == ctArray: expr(p, e.sons[0], d) else: var a: TLoc