changeset 283:9bb48fb57a7d trunk

[svn r304] Fix associative array literals by always reserving a zero inited temporary for them.
author ChristianK
date Sat, 21 Jun 2008 00:54:55 +0200
parents 74348f162225
children 70c370e97944
files gen/toir.cpp
diffstat 1 files changed, 6 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/gen/toir.cpp	Sat Jun 21 00:00:56 2008 +0200
+++ b/gen/toir.cpp	Sat Jun 21 00:54:55 2008 +0200
@@ -2815,17 +2815,12 @@
 
     Type* aatype = DtoDType(type);
     Type* vtype = aatype->next;
-
-    DValue* aa;
-    if (p->topexp() && p->topexp()->e2 == this)
-    {
-        aa = p->topexp()->v;
-    }
-    else
-    {
-        LLValue* tmp = new llvm::AllocaInst(DtoType(type),"aaliteral",p->topallocapoint());
-        aa = new DVarValue(type, tmp, true);
-    }
+    const LLType* aalltype = DtoType(type);
+
+    // it should be possible to avoid the temporary in some cases
+    LLValue* tmp = new llvm::AllocaInst(aalltype,"aaliteral",p->topallocapoint());
+    DValue* aa = new DVarValue(type, tmp, true);
+    DtoStore(LLConstant::getNullValue(aalltype), tmp);
 
     const size_t n = keys->dim;
     for (size_t i=0; i<n; ++i)