diff gen/toir.c @ 32:a86fe7496b58 trunk

[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
author lindquist
date Thu, 04 Oct 2007 18:24:05 +0200
parents 881158a93592
children 4648206ca213
line wrap: on
line diff
--- a/gen/toir.c	Thu Oct 04 16:44:07 2007 +0200
+++ b/gen/toir.c	Thu Oct 04 18:24:05 2007 +0200
@@ -986,6 +986,13 @@
         else {
             Logger::println("as ptr arg");
             llargs[j] = arg->mem ? arg->mem : arg->val;
+            if (llargs[j]->getType() != llfnty->getParamType(j))
+            {
+                assert(llargs[j]->getType() == llfnty->getParamType(j)->getContainedType(0));
+                LLVM_DtoGiveArgumentStorage(arg);
+                new llvm::StoreInst(llargs[j], arg->mem, p->scopebb());
+                llargs[j] = arg->mem;
+            }
             assert(llargs[j] != 0);
         }