Mercurial > projects > ldc
comparison gen/statements.cpp @ 185:89e21eeaf4c4 trunk
[svn r201] Fixed: return statement could fail codegen with type mismatch for classes, added cast.
author | lindquist |
---|---|
date | Wed, 07 May 2008 22:27:45 +0200 |
parents | ef4108f34db6 |
children | bfcb657756f6 |
comparison
equal
deleted
inserted
replaced
184:f5ca6bbbf1d7 | 185:89e21eeaf4c4 |
---|---|
100 if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); | 100 if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); |
101 DValue* e = exp->toElem(p); | 101 DValue* e = exp->toElem(p); |
102 llvm::Value* v = e->getRVal(); | 102 llvm::Value* v = e->getRVal(); |
103 delete e; | 103 delete e; |
104 Logger::cout() << "return value is '" <<*v << "'\n"; | 104 Logger::cout() << "return value is '" <<*v << "'\n"; |
105 | |
106 // can happen for classes | |
107 if (v->getType() != p->topfunc()->getReturnType()) | |
108 { | |
109 v = gIR->ir->CreateBitCast(v, p->topfunc()->getReturnType(), "tmp"); | |
110 Logger::cout() << "return value after cast: " << *v << '\n'; | |
111 } | |
105 | 112 |
106 emit_finallyblocks(p, enclosingtryfinally, NULL); | 113 emit_finallyblocks(p, enclosingtryfinally, NULL); |
107 | 114 |
108 if (global.params.symdebug) DtoDwarfFuncEnd(p->func()->decl); | 115 if (global.params.symdebug) DtoDwarfFuncEnd(p->func()->decl); |
109 new llvm::ReturnInst(v, p->scopebb()); | 116 new llvm::ReturnInst(v, p->scopebb()); |