Skip to content

Commit

Permalink
Merge pull request #5326 from WalterBright/fix15417
Browse files Browse the repository at this point in the history
fix Issue 15417 - Wrong parameter passing for variadic nested functio…
  • Loading branch information
andralex committed Dec 30, 2015
2 parents 7a49fad + 1ececaf commit 675a2d4
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/func.d
Expand Up @@ -1938,7 +1938,7 @@ public:
Expression e = new SymOffExp(Loc(), v_argsave, 6 * 8 + 8 * 16);
e.type = argptr.type;
e = new AssignExp(Loc(), e1, e);
e = e.semantic(sc);
e = e.semantic(sc2);
a.push(new ExpStatement(Loc(), e));
}
else
Expand Down
50 changes: 50 additions & 0 deletions test/runnable/variadic.d
Expand Up @@ -1074,6 +1074,55 @@ void test10722()
alias X10722 = GetSomething10722!(S10722.tupleof[0]);
}

/***************************************/

void testx15417(ulong c1, ...)
{
check(c1, _argptr, _arguments);
}

class C15417
{
private void method ()
{
void test1 (ulong c1, ...)
{
check(c1, _argptr, _arguments);
}

void test2 (ulong c1, ...)
{
va_list ap;
version (Win64)
va_start(ap, c1);
else version (X86_64)
va_start(ap, __va_argsave);
else version (X86)
va_start(ap, c1);

check(c1, ap, _arguments);
}

testx15417(4242UL, char.init);
test1(4242UL, char.init);
test2(4242UL, char.init);
}
}

void check (ulong c1, va_list arglist, TypeInfo[] ti)
{
assert(ti.length == 1);
assert(ti[0].toString() == "char");
assert(char.init == va_arg!(char)(arglist));
}

void test15417()
{
auto c = new C15417;
c.method;
}


/***************************************/

int main()
Expand Down Expand Up @@ -1124,6 +1173,7 @@ int main()
test9495();
testCopy();
test14179();
test15417();

return 0;
}

0 comments on commit 675a2d4

Please sign in to comment.