Mercurial > projects > ldc
changeset 976:fe93215deb82
Fix for fix from [974].
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Tue, 17 Feb 2009 19:08:38 +0100 |
parents | 067bb8f19c36 |
children | 3efbe9b0dd36 |
files | gen/statements.cpp |
diffstat | 1 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/gen/statements.cpp Tue Feb 17 18:57:11 2009 +0100 +++ b/gen/statements.cpp Tue Feb 17 19:08:38 2009 +0100 @@ -93,8 +93,12 @@ // can happen for classes and void main if (v->getType() != p->topfunc()->getReturnType()) { - // for main and a void expression: return 0 instead, else bitcast - if (p->topfunc() == p->mainFunc && v->getType() == LLType::VoidTy) + // for the main function this only happens if it is declared as void + // and then contains a return (exp); statement. Since the actual + // return type remains i32, we just throw away the exp value + // and return 0 instead + // if we're not in main, just bitcast + if (p->topfunc() == p->mainFunc) v = llvm::Constant::getNullValue(p->mainFunc->getReturnType()); else v = gIR->ir->CreateBitCast(v, p->topfunc()->getReturnType(), "tmp");