Mercurial > projects > ldc
changeset 428:8b7cee241e91
Enable insertion of missing terminator instruction for main.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Tue, 29 Jul 2008 15:58:45 +0200 |
parents | f1d37dc5d354 |
children | 6bd99cc5eb08 |
files | gen/functions.cpp |
diffstat | 1 files changed, 10 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- 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()); } }