Mercurial > projects > ldc
comparison dmd/expression.c @ 1611:3f728445fc42
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(-)
author | Leandro Lucarella <llucax@gmail.com> |
---|---|
date | Wed, 06 Jan 2010 15:18:21 -0300 |
parents | 1d0220dd613a |
children | 081c48283153 |
comparison
equal
deleted
inserted
replaced
1610:4f63d530861f | 1611:3f728445fc42 |
---|---|
661 if (!p->defaultArg) | 661 if (!p->defaultArg) |
662 { | 662 { |
663 if (tf->varargs == 2 && i + 1 == nparams) | 663 if (tf->varargs == 2 && i + 1 == nparams) |
664 goto L2; | 664 goto L2; |
665 error(loc, "expected %zu function arguments, not %zu", nparams, nargs); | 665 error(loc, "expected %zu function arguments, not %zu", nparams, nargs); |
666 break; | 666 return; |
667 } | 667 } |
668 arg = p->defaultArg; | 668 arg = p->defaultArg; |
669 #if DMDV2 | 669 #if DMDV2 |
670 if (arg->op == TOKdefault) | 670 if (arg->op == TOKdefault) |
671 { DefaultInitExp *de = (DefaultInitExp *)arg; | 671 { DefaultInitExp *de = (DefaultInitExp *)arg; |
682 { | 682 { |
683 //printf("\t\tvarargs == 2, p->type = '%s'\n", p->type->toChars()); | 683 //printf("\t\tvarargs == 2, p->type = '%s'\n", p->type->toChars()); |
684 if (arg->implicitConvTo(p->type)) | 684 if (arg->implicitConvTo(p->type)) |
685 { | 685 { |
686 if (nargs != nparams) | 686 if (nargs != nparams) |
687 error(loc, "expected %zu function arguments, not %zu", nparams, nargs); | 687 { error(loc, "expected %zu function arguments, not %zu", nparams, nargs); |
688 return; | |
689 } | |
688 goto L1; | 690 goto L1; |
689 } | 691 } |
690 L2: | 692 L2: |
691 Type *tb = p->type->toBasetype(); | 693 Type *tb = p->type->toBasetype(); |
692 Type *tret = p->isLazyArray(); | 694 Type *tret = p->isLazyArray(); |
898 | 900 |
899 #if !IN_LLVM | 901 #if !IN_LLVM |
900 // If D linkage and variadic, add _arguments[] as first argument | 902 // If D linkage and variadic, add _arguments[] as first argument |
901 if (tf->linkage == LINKd && tf->varargs == 1) | 903 if (tf->linkage == LINKd && tf->varargs == 1) |
902 { | 904 { |
903 Expression *e; | 905 assert(arguments->dim >= nparams); |
904 | 906 Expression *e = createTypeInfoArray(sc, (Expression **)&arguments->data[nparams], |
905 e = createTypeInfoArray(sc, (Expression **)&arguments->data[nparams], | |
906 arguments->dim - nparams); | 907 arguments->dim - nparams); |
907 arguments->insert(0, e); | 908 arguments->insert(0, e); |
908 } | 909 } |
909 #endif | 910 #endif |
910 } | 911 } |