diff --git a/gen/arrays.cpp b/gen/arrays.cpp index ee874ad5..a671fe22 100644 --- a/gen/arrays.cpp +++ b/gen/arrays.cpp @@ -75,7 +75,7 @@ void DtoArrayInit(Loc& loc, DValue* array, DValue* value) LLValue* val; // give slices and complex values storage (and thus an address to pass) - if (value->isSlice()) + if (value->isSlice() || value->type->ty == Tdelegate) { val = DtoAlloca(value->getType(), ".tmpparam"); DVarValue lval(value->getType(), val); diff --git a/gen/dvalue.cpp b/gen/dvalue.cpp index 98300a9b..549b7aca 100644 --- a/gen/dvalue.cpp +++ b/gen/dvalue.cpp @@ -13,11 +13,15 @@ DVarValue::DVarValue(Type* t, VarDeclaration* vd, LLValue* llvmValue) : DValue(t), var(vd), val(llvmValue) -{} +{ + assert(isaPointer(llvmValue)); +} DVarValue::DVarValue(Type* t, LLValue* llvmValue) : DValue(t), var(0), val(llvmValue) -{} +{ + assert(isaPointer(llvmValue)); +} LLValue* DVarValue::getLVal() { diff --git a/gen/tocall.cpp b/gen/tocall.cpp index f3854fc0..43f6f57b 100644 --- a/gen/tocall.cpp +++ b/gen/tocall.cpp @@ -356,10 +356,14 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions* // ... or a nested function context arg else if (nestedcall) { - LLValue* contextptr = DtoNestedContext(loc, dfnval->func); - contextptr = DtoBitCast(contextptr, getVoidPtrType()); + if (dfnval) { + LLValue* contextptr = DtoNestedContext(loc, dfnval->func); + contextptr = DtoBitCast(contextptr, getVoidPtrType()); + args.push_back(contextptr); + } else { + args.push_back(llvm::UndefValue::get(getVoidPtrType())); + } ++argiter; - args.push_back(contextptr); } else { diff --git a/ir/irvar.cpp b/ir/irvar.cpp index 148fa661..782b8bce 100644 --- a/ir/irvar.cpp +++ b/ir/irvar.cpp @@ -31,6 +31,7 @@ IrGlobal::IrGlobal(VarDeclaration* v): IrVar(v), IrLocal::IrLocal(VarDeclaration* v) : IrVar(v) { nestedIndex = -1; + byref = false; } //////////////////////////////////////////////////////////////////////////////