Skip to content

Commit

Permalink
merge D2 pull 617
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Jan 13, 2012
1 parent 343d38f commit 53cba19
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -3167,6 +3167,7 @@ Statement *ReturnStatement::semantic(Scope *sc)
FuncDeclaration *fd = sc->parent->isFuncDeclaration();
Scope *scx = sc;
int implicit0 = 0;
Expression *eorg = NULL;

if (fd->fes)
fd = fd->fes->func; // fd is now function enclosing foreach
Expand Down Expand Up @@ -3232,10 +3233,7 @@ Statement *ReturnStatement::semantic(Scope *sc)
else
fd->nrvo_can = 0;

if (fd->returnLabel && tbret->ty != Tvoid)
{
}
else if (fd->inferRetType)
if (fd->inferRetType)
{
Type *tfret = fd->type->nextOf();
if (tfret)
Expand All @@ -3253,11 +3251,17 @@ Statement *ReturnStatement::semantic(Scope *sc)
tbret = tret->toBasetype();
}
}
if (fd->returnLabel)
eorg = exp;
}
else if (tbret->ty != Tvoid)
{
if (fd->tintro)
exp = exp->implicitCastTo(sc, fd->type->nextOf());

// eorg isn't casted to tret (== fd->tintro->nextOf())
if (fd->returnLabel)
eorg = exp->copy();
exp = exp->implicitCastTo(sc, tret);
}
}
Expand Down Expand Up @@ -3343,7 +3347,8 @@ Statement *ReturnStatement::semantic(Scope *sc)
assert(fd->vresult);
VarExp *v = new VarExp(0, fd->vresult);

exp = new AssignExp(loc, v, exp);
assert(eorg);
exp = new AssignExp(loc, v, eorg);
exp->op = TOKconstruct;
exp = exp->semantic(sc);
}
Expand Down

0 comments on commit 53cba19

Please sign in to comment.