Fix for the tuple assignment error in test aliasthis.d

The DMD front end uses a hack to avoid a "has no effect" error. This
hack must be recognised by LDC, too.
This commit is contained in:
Kai Nacke
2013-11-10 20:34:48 +01:00
parent 9ecd0da1b6
commit 7743f56450

View File

@@ -571,14 +571,22 @@ DValue* DtoCastInt(Loc& loc, DValue* val, Type* _to)
Type* from = val->getType()->toBasetype();
assert(from->isintegral());
size_t fromsz = from->size();
size_t tosz = to->size();
LLValue* rval = val->getRVal();
if (rval->getType() == tolltype) {
return new DImValue(_to, rval);
}
// Check for special DMD hack to avoid "has no effect" error.
// See expression.c, method AssignExp::semantic(), around line 11499
llvm::ConstantInt* isConstInt = isaConstantInt(rval);
if (from == Type::tint32 && to == Type::tvoid && isConstInt->isNullValue())
{
return val;
}
size_t fromsz = from->size();
size_t tosz = to->size();
if (to->ty == Tbool) {
LLValue* zero = LLConstantInt::get(rval->getType(), 0, false);
rval = gIR->ir->CreateICmpNE(rval, zero, "tmp");