changeset 859:a719f2ca3e92

Applied modification of wilsonk's patch for AndAnd and OrOrExp for void rhs funcs.
author Christian Kamm <kamm incasoftware de>
date Wed, 17 Dec 2008 21:24:17 +0100
parents ebbbf8c3ce93
children 7edce7e58ab1
files gen/toir.cpp tests/mini/andand.d
diffstat 2 files changed, 17 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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);
 }
 
--- /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); }
+