Implicitly cast return expressions to the return type of the function.

This commit is contained in:
Stefano Sanfilippo 2015-03-09 01:11:13 +01:00
parent eca4769534
commit 4037a76c6b

View File

@ -235,7 +235,8 @@ BitcodeEmitter::~BitcodeEmitter() {
bool BitcodeEmitter::emit(Return const& node) { bool BitcodeEmitter::emit(Return const& node) {
if (node.getExpression()) { if (node.getExpression()) {
GUARDED(node.getExpression()->emit(this)); GUARDED(node.getExpression()->emit(this));
d->builder.CreateRet(d->retval); llvm::Type *type = d->builder.GetInsertBlock()->getParent()->getReturnType();
d->builder.CreateRet(coerce(d, d->retval, type));
} else { } else {
d->builder.CreateRetVoid(); d->builder.CreateRetVoid();
} }