# HG changeset patch # User Christian Kamm # Date 1229545457 -3600 # Node ID a719f2ca3e927147a99995418fde8a8574dceb07 # Parent ebbbf8c3ce937c2afb1423e0ae4c3ec70bca064c Applied modification of wilsonk's patch for AndAnd and OrOrExp for void rhs funcs. diff -r ebbbf8c3ce93 -r a719f2ca3e92 gen/toir.cpp --- a/gen/toir.cpp Wed Dec 17 21:03:06 2008 +0100 +++ b/gen/toir.cpp Wed Dec 17 21:24:17 2008 +0100 @@ -1795,11 +1795,14 @@ 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); + 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 @@ p->scope() = IRScope(oror, ororend); DValue* v = e2->toElem(p); - LLValue* vbool = DtoCast(loc, v, Type::tbool)->getRVal(); - DtoStore(vbool,resval); + 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); } diff -r ebbbf8c3ce93 -r a719f2ca3e92 tests/mini/andand.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/mini/andand.d Wed Dec 17 21:24:17 2008 +0100 @@ -0,0 +1,3 @@ +bool ok = false; +void f(){ ok = true; } void main() { bool b=true; b && f(); assert(ok); } +