Skip to content

Commit

Permalink
Merge branch 'master' of github.com:D-Programming-Language/dmd
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Apr 6, 2013
2 parents 4ba485b + bea22e3 commit d66440d
Show file tree
Hide file tree
Showing 5 changed files with 275 additions and 138 deletions.
25 changes: 25 additions & 0 deletions src/delegatize.c
Expand Up @@ -19,6 +19,7 @@
#include "declaration.h"
#include "aggregate.h"
#include "scope.h"
#include "init.h"

/********************************************
* Convert from expression to delegate that returns the expression,
Expand Down Expand Up @@ -136,6 +137,30 @@ int lambdaCheckForNestedRef(Expression *e, void *param)
break;
}

case TOKdeclaration:
{ DeclarationExp *de = (DeclarationExp *)e;
VarDeclaration *v = de->declaration->isVarDeclaration();
if (v)
{
v->checkNestedReference(sc, 0);

/* Some expressions cause the frontend to create a temporary.
* For example, structs with cpctors replace the original
* expression e with:
* __cpcttmp = __cpcttmp.cpctor(e);
*
* In this instance, we need to ensure that the original
* expression e does not have any nested references by
* checking the declaration initializer too.
*/
if (v->init && v->init->isExpInitializer())
{ Expression *ie = v->init->toExpression();
ie->apply (&lambdaCheckForNestedRef, param);
}
}
break;
}

default:
break;
}
Expand Down
5 changes: 5 additions & 0 deletions src/func.c
Expand Up @@ -2771,6 +2771,11 @@ FuncDeclaration *resolveFuncCall(Loc loc, Scope *sc, Dsymbol *s,
{
if (!s)
return NULL; // no match
if (tiargs && arrayObjectIsError(tiargs) ||
arguments && arrayObjectIsError((Objects *)arguments))
{
return NULL;
}
FuncDeclaration *f = s->isFuncDeclaration();
if (f)
f = f->overloadResolve(loc, ethis, arguments, flags);
Expand Down
8 changes: 2 additions & 6 deletions src/optimize.c
Expand Up @@ -516,12 +516,8 @@ Expression *CallExp::optimize(int result, bool keepLvalue)
size_t pdim = Parameter::dim(tf->parameters) - (tf->varargs == 2 ? 1 : 0);
for (size_t i = 0; i < arguments->dim; i++)
{
bool keepLvalue = false;
if (i < pdim)
{
Parameter *p = Parameter::getNth(tf->parameters, i);
keepLvalue = ((p->storageClass & (STCref | STCout)) != 0);
}
Parameter *p = Parameter::getNth(tf->parameters, i);
bool keepLvalue = (p ? (p->storageClass & (STCref | STCout)) != 0 : false);
Expression *e = (*arguments)[i];
e = e->optimize(WANTvalue, keepLvalue);
(*arguments)[i] = e;
Expand Down

0 comments on commit d66440d

Please sign in to comment.