Special case DtoCastInt for bool.

This commit is contained in:
Christian Kamm 2008-11-10 20:55:24 +01:00
parent bc80a83666
commit fe49ee6448

View file

@ -570,7 +570,7 @@ DValue* DtoCastInt(Loc& loc, DValue* val, Type* _to)
}
if (to->isintegral()) {
if (fromsz < tosz) {
if (fromsz < tosz || from->ty == Tbool) {
if (Logger::enabled())
Logger::cout() << "cast to: " << *tolltype << '\n';
if (from->isunsigned() || from->ty == Tbool) {
@ -579,7 +579,7 @@ DValue* DtoCastInt(Loc& loc, DValue* val, Type* _to)
rval = new llvm::SExtInst(rval, tolltype, "tmp", gIR->scopebb());
}
}
else if (fromsz > tosz) {
else if (fromsz > tosz || to->ty == Tbool) {
rval = new llvm::TruncInst(rval, tolltype, "tmp", gIR->scopebb());
}
else {