diff --git a/gen/toir.c b/gen/toir.c index 66b1659ada..8845c8d5d8 100644 --- a/gen/toir.c +++ b/gen/toir.c @@ -1027,9 +1027,11 @@ elem* CallExp::toElem(IRState* p) llvm::FunctionType::param_iterator argiter = llfnty->param_begin(); int j = 0; + Logger::println("hidden struct return"); + // hidden struct return arguments if (retinptr) { - if (!p->lvals.empty()) { + if (!p->lvals.empty() && p->toplval()) { assert(llvm::isa(p->toplval()->getType()->getContainedType(0))); llargs[j] = p->toplval(); if (LLVM_DtoIsPassedByRef(tf->next)) { @@ -1049,6 +1051,8 @@ elem* CallExp::toElem(IRState* p) e->type = elem::VAL; } + Logger::println("this arguments"); + // this arguments if (fn->arg) { Logger::println("This Call"); @@ -1071,6 +1075,8 @@ elem* CallExp::toElem(IRState* p) ++argiter; } + Logger::println("regular arguments"); + // regular arguments for (int i=0; idim; i++,j++) { @@ -1471,7 +1477,7 @@ elem* StructLiteralExp::toElem(IRState* p) llvm::Value* sptr = 0; // if there is no lval, this is probably a temporary struct literal. correct? - if (p->lvals.empty()) + if (p->lvals.empty() || !p->toplval()) { sptr = new llvm::AllocaInst(LLVM_DtoType(type),"tmpstructliteral",p->topallocapoint()); e->mem = sptr; @@ -2514,7 +2520,7 @@ elem* ArrayLiteralExp::toElem(IRState* p) Logger::cout() << "array literal has llvm type: " << *t << '\n'; llvm::Value* mem = 0; - if (p->lvals.empty()) { + if (p->lvals.empty() || !p->toplval()) { assert(LLVM_DtoDType(type)->ty == Tsarray); mem = new llvm::AllocaInst(t,"tmparrayliteral",p->topallocapoint()); } diff --git a/test/bug17.d b/test/bug17.d new file mode 100644 index 0000000000..663106bdf8 --- /dev/null +++ b/test/bug17.d @@ -0,0 +1,13 @@ +module bug17; + +struct Vec +{ + Vec opAdd(ref Vec b) { return Vec(); } + Vec opMul(double a) { return Vec(); } +} +void main() +{ + Vec foo; + Vec bar; + auto whee=foo+bar*1f; +}