# HG changeset patch # User Christian Kamm # Date 1234894118 -3600 # Node ID fe93215deb821694f45a4be5a9fbed59a647d11b # Parent 067bb8f19c36381767082818eabefd9871d07337 Fix for fix from [974]. diff -r 067bb8f19c36 -r fe93215deb82 gen/statements.cpp --- 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");