Mercurial > projects > ldc
diff gen/functions.cpp @ 225:74701ba40398 trunk
[svn r241] Fixed missing terminator for void main() with inline asm block.
author | lindquist |
---|---|
date | Fri, 06 Jun 2008 22:30:31 +0200 |
parents | 0806379a5eca |
children | 9760f54af0b7 |
line wrap: on
line diff
--- a/gen/functions.cpp Fri Jun 06 22:04:41 2008 +0200 +++ b/gen/functions.cpp Fri Jun 06 22:30:31 2008 +0200 @@ -694,6 +694,19 @@ } } + // if the last block is not terminated we return a null value or void + // for some unknown reason this is needed when a void main() has a inline asm block ... + // this should be harmless for well formed code! + lastbb = &func->getBasicBlockList().back(); + if (!lastbb->getTerminator()) + { + Logger::println("adding missing return statement"); + if (func->getReturnType() == llvm::Type::VoidTy) + llvm::ReturnInst::Create(lastbb); + else + llvm::ReturnInst::Create(llvm::Constant::getNullValue(func->getReturnType()), lastbb); + } + gIR->functions.pop_back(); } }