Skip to content

Commit

Permalink
merge D2 pull 598
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Jan 6, 2012
1 parent dd7eb4e commit 21ce18f
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/expression.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,20 +728,24 @@ void functionParameters(Loc loc, Scope *sc, TypeFunction *tf, Expressions *argum
*/
if (!tf->parameterEscapes(p))
{
Expression *a = arg;
if (a->op == TOKcast)
a = ((CastExp *)a)->e1;

/* Function literals can only appear once, so if this
* appearance was scoped, there cannot be any others.
*/
if (arg->op == TOKfunction)
{ FuncExp *fe = (FuncExp *)arg;
if (a->op == TOKfunction)
{ FuncExp *fe = (FuncExp *)a;
fe->fd->tookAddressOf = 0;
}

/* For passing a delegate to a scoped parameter,
* this doesn't count as taking the address of it.
* We only worry about 'escaping' references to the function.
*/
else if (arg->op == TOKdelegate)
{ DelegateExp *de = (DelegateExp *)arg;
else if (a->op == TOKdelegate)
{ DelegateExp *de = (DelegateExp *)a;
if (de->e1->op == TOKvar)
{ VarExp *ve = (VarExp *)de->e1;
FuncDeclaration *f = ve->var->isFuncDeclaration();
Expand Down Expand Up @@ -6656,6 +6660,14 @@ Expression *CallExp::semantic(Scope *sc)
e1 = new DsymbolExp(loc, se->sds);
e1 = e1->semantic(sc);
}
#if DMDV2
else if (e1->op == TOKsymoff && ((SymOffExp *)e1)->hasOverloads)
{
SymOffExp *se = (SymOffExp *)e1;
e1 = new VarExp(se->loc, se->var, 1);
e1 = e1->semantic(sc);
}
#endif
#if 1 // patch for #540 by Oskar Linde
else if (e1->op == TOKdotexp)
{
Expand Down Expand Up @@ -6884,6 +6896,7 @@ Expression *CallExp::semantic(Scope *sc)
checkDeprecated(sc, f);
#if DMDV2
checkPurity(sc, f);
checkSafety(sc, f);
#endif
e1 = new DotVarExp(e1->loc, e1, f);
e1 = e1->semantic(sc);
Expand Down

0 comments on commit 21ce18f

Please sign in to comment.