Mercurial > projects > ldc
comparison 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 |
comparison
equal
deleted
inserted
replaced
224:116cc012409b | 225:74701ba40398 |
---|---|
692 llvm::ReturnInst::Create(llvm::UndefValue::get(func->getReturnType()), lastbb); | 692 llvm::ReturnInst::Create(llvm::UndefValue::get(func->getReturnType()), lastbb); |
693 }*/ | 693 }*/ |
694 } | 694 } |
695 } | 695 } |
696 | 696 |
697 // if the last block is not terminated we return a null value or void | |
698 // for some unknown reason this is needed when a void main() has a inline asm block ... | |
699 // this should be harmless for well formed code! | |
700 lastbb = &func->getBasicBlockList().back(); | |
701 if (!lastbb->getTerminator()) | |
702 { | |
703 Logger::println("adding missing return statement"); | |
704 if (func->getReturnType() == llvm::Type::VoidTy) | |
705 llvm::ReturnInst::Create(lastbb); | |
706 else | |
707 llvm::ReturnInst::Create(llvm::Constant::getNullValue(func->getReturnType()), lastbb); | |
708 } | |
709 | |
697 gIR->functions.pop_back(); | 710 gIR->functions.pop_back(); |
698 } | 711 } |
699 } | 712 } |
700 } | 713 } |
701 | 714 |