diff --git a/gen/tocall.cpp b/gen/tocall.cpp index ebe2a22e..cd343820 100644 --- a/gen/tocall.cpp +++ b/gen/tocall.cpp @@ -688,6 +688,27 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions* retllval = DtoBitCast(retllval, DtoType(rbase)); break; +#if DMDV2 + case Tstruct: + if (nextbase->ty == Taarray && !tf->isref) + { + // In the D2 frontend, the associative array type and its + // object.AssociativeArray representation are used + // interchangably in some places. However, AAs are returned + // by value and not in an sret argument, so if the struct + // type will be used, give the return value storage here + // so that we get the right amount of indirections. + LLValue* tmp = DtoAlloca(rbase, ".aalvauetmp"); + LLValue* val = DtoInsertValue( + llvm::UndefValue::get(DtoType(rbase)), retllval, 0); + DtoStore(val, tmp); + retllval = tmp; + retinptr = true; + break; + } + // Fall through. +#endif + default: // Unfortunately, DMD has quirks resp. bugs with regard to name // mangling: For voldemort-type functions which return a nested @@ -721,6 +742,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions* // } // void main() { auto r = iota(); } // --- + Logger::println("Unknown return mismatch type, ignoring."); break; } if (Logger::enabled()) diff --git a/tests/d2/dmd-testsuite b/tests/d2/dmd-testsuite index 910e0198..7200e8bd 160000 --- a/tests/d2/dmd-testsuite +++ b/tests/d2/dmd-testsuite @@ -1 +1 @@ -Subproject commit 910e0198ae0be3c04370c84f33dcac36577ed390 +Subproject commit 7200e8bd3307b7caad50800243d3474582c9c982