mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-09-28 08:10:18 +02:00
Merge DMD r277: bugzilla 3495 Segfault(typinf.c) instantiating D variadic...
bugzilla 3495 Segfault(typinf.c) instantiating D variadic function with too few arguments. --- dmd/expression.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-)
This commit is contained in:
+6
-5
@@ -663,7 +663,7 @@ void functionParameters(Loc loc, Scope *sc, TypeFunction *tf, Expressions *argum
|
|||||||
if (tf->varargs == 2 && i + 1 == nparams)
|
if (tf->varargs == 2 && i + 1 == nparams)
|
||||||
goto L2;
|
goto L2;
|
||||||
error(loc, "expected %zu function arguments, not %zu", nparams, nargs);
|
error(loc, "expected %zu function arguments, not %zu", nparams, nargs);
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
arg = p->defaultArg;
|
arg = p->defaultArg;
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
@@ -684,7 +684,9 @@ void functionParameters(Loc loc, Scope *sc, TypeFunction *tf, Expressions *argum
|
|||||||
if (arg->implicitConvTo(p->type))
|
if (arg->implicitConvTo(p->type))
|
||||||
{
|
{
|
||||||
if (nargs != nparams)
|
if (nargs != nparams)
|
||||||
error(loc, "expected %zu function arguments, not %zu", nparams, nargs);
|
{ error(loc, "expected %zu function arguments, not %zu", nparams, nargs);
|
||||||
|
return;
|
||||||
|
}
|
||||||
goto L1;
|
goto L1;
|
||||||
}
|
}
|
||||||
L2:
|
L2:
|
||||||
@@ -900,9 +902,8 @@ void functionParameters(Loc loc, Scope *sc, TypeFunction *tf, Expressions *argum
|
|||||||
// If D linkage and variadic, add _arguments[] as first argument
|
// If D linkage and variadic, add _arguments[] as first argument
|
||||||
if (tf->linkage == LINKd && tf->varargs == 1)
|
if (tf->linkage == LINKd && tf->varargs == 1)
|
||||||
{
|
{
|
||||||
Expression *e;
|
assert(arguments->dim >= nparams);
|
||||||
|
Expression *e = createTypeInfoArray(sc, (Expression **)&arguments->data[nparams],
|
||||||
e = createTypeInfoArray(sc, (Expression **)&arguments->data[nparams],
|
|
||||||
arguments->dim - nparams);
|
arguments->dim - nparams);
|
||||||
arguments->insert(0, e);
|
arguments->insert(0, e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user