mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-02-26 08:33:14 +01:00
Applied modification of wilsonk's patch for AndAnd and OrOrExp for void rhs funcs.
This commit is contained in:
22
gen/toir.cpp
22
gen/toir.cpp
@@ -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
3
tests/mini/andand.d
Normal file
@@ -0,0 +1,3 @@
|
||||
bool ok = false;
|
||||
void f(){ ok = true; } void main() { bool b=true; b && f(); assert(ok); }
|
||||
|
||||
Reference in New Issue
Block a user