Fix cast problem with implicit constructors.

This commit is contained in:
Kai Nacke
2013-11-12 08:23:06 +01:00
parent 7743f56450
commit 015cf202e1
2 changed files with 11 additions and 0 deletions

View File

@@ -11678,7 +11678,10 @@ Ltupleassign:
ex = ex->modifiableLvalue(sc, ex); // allocate new slot
ey = new ConstructExp(loc, ex, ey);
#if !IN_LLVM
// Do not cast the value to void. Same as in 2.065.
e = new CastExp(e->loc, e, Type::tvoid);
#endif
ey = new CastExp(ey->loc, ey, Type::tvoid);
}
}

View File

@@ -1140,6 +1140,14 @@ DValue* CastExp::toElem(IRState* p)
// get the value to cast
DValue* u = e1->toElem(p);
// a constructor expression is casted to void in order to mark
// the value as unused. See expression.d, method AssignExp::semantic(),
// around line 11681
if (to == Type::tvoid && e1->op == TOKconstruct)
{
return new DNullValue(Type::tvoid, 0);
}
// cast it to the 'to' type, if necessary
DValue* v = u;
if (!to->equals(e1->type))