From ddfa41938fdbddf29534791aa3cba37b7accff46 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Sat, 21 Jun 2008 00:54:55 +0200 Subject: [PATCH] [svn r304] Fix associative array literals by always reserving a zero inited temporary for them. --- gen/toir.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/gen/toir.cpp b/gen/toir.cpp index f4414de1..8ee60dec 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -2815,17 +2815,12 @@ DValue* AssocArrayLiteralExp::toElem(IRState* p) Type* aatype = DtoDType(type); Type* vtype = aatype->next; + const LLType* aalltype = DtoType(type); - 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); - } + // 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