diff --git a/gen/functions.cpp b/gen/functions.cpp index 8d641a14a9..cddaaac6b0 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -141,6 +141,17 @@ const llvm::FunctionType* DtoFunctionType(Type* type, const LLType* thistype, bo paramvec.push_back(at); } + // handle lazy args + if (arg->storageClass & STClazy) + { + Logger::cout() << "for lazy got: " << *paramvec.back() << '\n'; + TypeFunction *ltf = new TypeFunction(NULL, arg->type, 0, LINKd); + TypeDelegate *ltd = new TypeDelegate(ltf); + at = getPtrToType(DtoType(ltd)); + Logger::cout() << "lazy updated to: " << *at << '\n'; + paramvec.back() = at; + } + if (arg->llvmByVal) nbyval++; } diff --git a/tangotests/lazy1.d b/tangotests/lazy1.d new file mode 100644 index 0000000000..aed6458125 --- /dev/null +++ b/tangotests/lazy1.d @@ -0,0 +1,13 @@ +module tangotests.lazy1; + +extern(C) int printf(char*, ...); + +void main() +{ + lazystr("whee\n"); +} + +void lazystr(lazy char[] msg) +{ + printf("%.*s", msg.length, msg.ptr); +}