mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-17 13:23:14 +01:00
Fix for fix from [974].
This commit is contained in:
@@ -93,8 +93,12 @@ void ReturnStatement::toIR(IRState* p)
|
||||
// can happen for classes and void main
|
||||
if (v->getType() != p->topfunc()->getReturnType())
|
||||
{
|
||||
// for main and a void expression: return 0 instead, else bitcast
|
||||
if (p->topfunc() == p->mainFunc && v->getType() == LLType::VoidTy)
|
||||
// for the main function this only happens if it is declared as void
|
||||
// and then contains a return (exp); statement. Since the actual
|
||||
// return type remains i32, we just throw away the exp value
|
||||
// and return 0 instead
|
||||
// if we're not in main, just bitcast
|
||||
if (p->topfunc() == p->mainFunc)
|
||||
v = llvm::Constant::getNullValue(p->mainFunc->getReturnType());
|
||||
else
|
||||
v = gIR->ir->CreateBitCast(v, p->topfunc()->getReturnType(), "tmp");
|
||||
|
||||
Reference in New Issue
Block a user