Applied modification of wilsonk's patch for AndAnd and OrOrExp for void rhs funcs.

This commit is contained in:
Christian Kamm
2008-12-17 21:24:17 +01:00
parent 0e1b27db3c
commit 7069073f75
2 changed files with 17 additions and 8 deletions

View File

@@ -1795,11 +1795,14 @@ DValue* AndAndExp::toElem(IRState* p)
p->scope() = IRScope(andand, andandend);
DValue* v = e2->toElem(p);
LLValue* vbool = DtoCast(loc, v, Type::tbool)->getRVal();
LLValue* uandvbool = llvm::BinaryOperator::Create(llvm::BinaryOperator::And, ubool, vbool,"tmp",p->scopebb());
DtoStore(uandvbool,resval);
llvm::BranchInst::Create(andandend,p->scopebb());
if (!v->isFunc() && v->getType() != Type::tvoid)
{
LLValue* vbool = DtoCast(loc, v, Type::tbool)->getRVal();
LLValue* uandvbool = llvm::BinaryOperator::Create(llvm::BinaryOperator::And, ubool, vbool,"tmp",p->scopebb());
DtoStore(uandvbool,resval);
}
llvm::BranchInst::Create(andandend,p->scopebb());
p->scope() = IRScope(andandend, oldend);
resval = DtoLoad(resval);
@@ -1830,13 +1833,16 @@ DValue* OrOrExp::toElem(IRState* p)
p->scope() = IRScope(oror, ororend);
DValue* v = e2->toElem(p);
LLValue* vbool = DtoCast(loc, v, Type::tbool)->getRVal();
DtoStore(vbool,resval);
llvm::BranchInst::Create(ororend,p->scopebb());
if (!v->isFunc() && v->getType() != Type::tvoid)
{
LLValue* vbool = DtoCast(loc, v, Type::tbool)->getRVal();
DtoStore(vbool,resval);
}
llvm::BranchInst::Create(ororend,p->scopebb());
p->scope() = IRScope(ororend, oldend);
resval = new llvm::LoadInst(resval,"tmp",p->scopebb());
resval = DtoLoad(resval);
return new DImValue(type, resval);
}

3
tests/mini/andand.d Normal file
View File

@@ -0,0 +1,3 @@
bool ok = false;
void f(){ ok = true; } void main() { bool b=true; b && f(); assert(ok); }