Mercurial > projects > ldc
changeset 1427:087dafe5262a
Make sure complex -> integral casts are not used when casting to bool.
Error instead of assert on unimplemented cast.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Thu, 28 May 2009 21:45:14 +0200 |
parents | ae70c438b281 |
children | c6cc9cf12bec |
files | gen/complex.cpp |
diffstat | 1 files changed, 5 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/gen/complex.cpp Thu May 28 20:26:26 2009 +0200 +++ b/gen/complex.cpp Thu May 28 21:45:14 2009 +0200 @@ -410,7 +410,7 @@ DValue* DtoCastComplex(Loc& loc, DValue* val, Type* _to) { Type* to = _to->toBasetype(); - Type* vty = val->getType(); + Type* vty = val->getType()->toBasetype(); if (to->iscomplex()) { if (vty->size() == to->size()) return val; @@ -438,6 +438,9 @@ DImValue* im = new DImValue(to, impart); return DtoCastFloat(loc, im, to); } + else if (to->ty == Tbool) { + return new DImValue(_to, DtoComplexEquals(loc, TOKnotequal, val, DtoNullValue(vty))); + } else if (to->isfloating() || to->isintegral()) { // FIXME: this loads both values, even when we only need one LLValue* v = val->getRVal(); @@ -453,10 +456,7 @@ DImValue* re = new DImValue(extractty, repart); return DtoCastFloat(loc, re, to); } - else if (to->ty == Tbool) { - return new DImValue(_to, DtoComplexEquals(loc, TOKnotequal, val, DtoNullValue(vty))); - } else - assert(0); + error(loc, "Don't know how to cast %s to %s", vty->toChars(), to->toChars()); }