diff --git a/dmd2/func.c b/dmd2/func.c index 2f8bccd5..2aecdfd6 100644 --- a/dmd2/func.c +++ b/dmd2/func.c @@ -1670,10 +1670,14 @@ void FuncDeclaration::semantic3(Scope *sc) { #if IN_LLVM Expression *e = 0; - if (isCtorDeclaration()) - e = new VarExp(0, vthis); - else + if (isCtorDeclaration()) { + ThisExp *te = new ThisExp(0); + te->type = vthis->type; + te->var = vthis; + e = te; + } else { e = new VarExp(0, vresult); + } #else // Create: return vresult; assert(vresult); diff --git a/dmd2/statement.c b/dmd2/statement.c index 2ca6d8f0..401df707 100644 --- a/dmd2/statement.c +++ b/dmd2/statement.c @@ -3686,7 +3686,11 @@ Statement *ReturnStatement::semantic(Scope *sc) else { // Construct: return vresult; +#if IN_LLVM + if (!fd->vresult && !fd->isCtorDeclaration()) +#else if (!fd->vresult) +#endif { // Declare vresult VarDeclaration *v = new VarDeclaration(loc, tret, Id::result, NULL); v->noscope = 1; @@ -3698,7 +3702,11 @@ Statement *ReturnStatement::semantic(Scope *sc) fd->vresult = v; } +#if IN_LLVM + s = new ReturnStatement(0, new VarExp(0, fd->isCtorDeclaration() ? fd->vthis : fd->vresult)); +#else s = new ReturnStatement(0, new VarExp(0, fd->vresult)); +#endif sc->fes->cases->push(s); // Construct: { vresult = exp; return cases->dim + 1; }