From b7ca040f7c6a46d4d0c671858cd9bea71096ab1e Mon Sep 17 00:00:00 2001 From: Frits van Bommel Date: Mon, 30 Mar 2009 00:00:43 +0200 Subject: [PATCH] Fix a bug I noticed. Varargs were broken if preceded by tuple parameters. --- gen/tocall.cpp | 4 +++- tests/mini/tuple_and_vararg.d | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 tests/mini/tuple_and_vararg.d diff --git a/gen/tocall.cpp b/gen/tocall.cpp index f13c044f..a48ad2b1 100644 --- a/gen/tocall.cpp +++ b/gen/tocall.cpp @@ -122,11 +122,12 @@ const LLFunctionType* DtoExtractFunctionType(const LLType* type) void DtoBuildDVarArgList(std::vector& args, std::vector& attrs, TypeFunction* tf, Expressions* arguments, size_t argidx) { Logger::println("doing d-style variadic arguments"); + LOG_SCOPE std::vector vtypes; // number of non variadic args - int begin = tf->parameters->dim; + int begin = Argument::dim(tf->parameters); Logger::println("num non vararg params = %d", begin); // get n args in arguments list @@ -136,6 +137,7 @@ void DtoBuildDVarArgList(std::vector& args, std::vectordata[i]; + assert(argexp->type->ty != Ttuple); vtypes.push_back(DtoType(argexp->type)); size_t sz = getTypePaddedSize(vtypes.back()); if (sz < PTRSIZE) diff --git a/tests/mini/tuple_and_vararg.d b/tests/mini/tuple_and_vararg.d new file mode 100644 index 00000000..a6d3d901 --- /dev/null +++ b/tests/mini/tuple_and_vararg.d @@ -0,0 +1,13 @@ +// Based on dstress.run.t.tuple_15_A; + +module tuple_and_vararg; + +template TypeTuple(TList...){ + alias TList TypeTuple; +} + +void main(){ + auto y = function(TypeTuple!(uint,uint) ab, ...){}; + y(1, 2); + y(1, 2, "foo", 3.0); +}