summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2013-05-20 12:33:07 +0200
committerAraq <rumpf_a@web.de>2013-05-20 12:33:07 +0200
commit4fd900f3d5bfe2a686e3f4d7a7a5b68f3a2318cd (patch)
tree2956949a4001280a85237a75704399fe2def25d4 /compiler
parent1100521b6e32312f182acffc2b739dd678c67f65 (diff)
downloadNim-4fd900f3d5bfe2a686e3f4d7a7a5b68f3a2318cd.tar.gz
attempt to fix a codegen bug
Diffstat (limited to 'compiler')
-rw-r--r--compiler/ccgexprs.nim8
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim
index 410e65ac9..a5c4a8de7 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