# HG changeset patch # User Christian Kamm # Date 1217339925 -7200 # Node ID 8b7cee241e91d6f7ebfc50e7e88c70ba7417955b # Parent f1d37dc5d354a5c2b964a9c98c439bee2f27cc73 Enable insertion of missing terminator instruction for main. diff -r f1d37dc5d354 -r 8b7cee241e91 gen/functions.cpp --- a/gen/functions.cpp Tue Jul 29 13:48:46 2008 +0200 +++ b/gen/functions.cpp Tue Jul 29 15:58:45 2008 +0200 @@ -695,16 +695,17 @@ // llvm requires all basic blocks to end with a TerminatorInst but DMD does not put a return statement // in automatically, so we do it here. - if (!fd->isMain()) { - if (!gIR->scopereturned()) { - // pass the previous block into this block - if (global.params.symdebug) DtoDwarfFuncEnd(fd); - if (func->getReturnType() == LLType::VoidTy) { - llvm::ReturnInst::Create(gIR->scopebb()); - } - else { + if (!gIR->scopereturned()) { + // pass the previous block into this block + if (global.params.symdebug) DtoDwarfFuncEnd(fd); + if (func->getReturnType() == LLType::VoidTy) { + llvm::ReturnInst::Create(gIR->scopebb()); + } + else { + if (!fd->isMain()) llvm::ReturnInst::Create(llvm::UndefValue::get(func->getReturnType()), gIR->scopebb()); - } + else + llvm::ReturnInst::Create(llvm::Constant::getNullValue(func->getReturnType()), gIR->scopebb()); } }