[svn r201] Fixed: return statement could fail codegen with type mismatch for classes, added cast.

This commit is contained in:
Tomas Lindquist Olsen
2008-05-07 22:27:45 +02:00
parent fa30c42921
commit 81ae45afe8

View File

@@ -103,6 +103,13 @@ void ReturnStatement::toIR(IRState* p)
delete e;
Logger::cout() << "return value is '" <<*v << "'\n";
// can happen for classes
if (v->getType() != p->topfunc()->getReturnType())
{
v = gIR->ir->CreateBitCast(v, p->topfunc()->getReturnType(), "tmp");
Logger::cout() << "return value after cast: " << *v << '\n';
}
emit_finallyblocks(p, enclosingtryfinally, NULL);
if (global.params.symdebug) DtoDwarfFuncEnd(p->func()->decl);