Allow casting AAs to bool.

Fixed DMD testcase 'nulltype'.
This commit is contained in:
David Nadlinger
2013-06-14 16:01:09 +02:00
parent 9c0514a9b1
commit 86563a2ee1

View File

@@ -821,6 +821,13 @@ DValue* DtoCast(Loc& loc, DValue* val, Type* to)
LLValue *rval = DtoBitCast(val->getRVal(), DtoType(to));
return new DImValue(to, rval);
}
else if (totype->ty == Tbool)
{
IF_LOG Logger::println("Casting AA to bool.");
LLValue* rval = val->getRVal();
LLValue* zero = LLConstant::getNullValue(rval->getType());
return new DImValue(to, gIR->ir->CreateICmpNE(rval, zero));
}
// Else try dealing with the rewritten (struct) type.
fromtype = static_cast<TypeAArray*>(fromtype)->getImpl()->type;