# HG changeset patch # User Christian Kamm # Date 1243535186 -7200 # Node ID ae70c438b281c89c264112d6354078af59439eb4 # Parent 925779c1939579bb74b9f01f57860344741b0d26 Allow complex -> integral casts. diff -r 925779c19395 -r ae70c438b281 gen/complex.cpp --- a/gen/complex.cpp Thu May 28 02:28:30 2009 +0200 +++ b/gen/complex.cpp Thu May 28 20:26:26 2009 +0200 @@ -438,11 +438,19 @@ DImValue* im = new DImValue(to, impart); return DtoCastFloat(loc, im, to); } - else if (to->isfloating()) { + else if (to->isfloating() || to->isintegral()) { // FIXME: this loads both values, even when we only need one LLValue* v = val->getRVal(); LLValue* repart = gIR->ir->CreateExtractValue(v, 0, ".re_part"); - DImValue* re = new DImValue(to, repart); + Type *extractty; + if (vty->ty == Tcomplex32) { + extractty = Type::tfloat32; + } else if (vty->ty == Tcomplex64) { + extractty = Type::tfloat64; + } else if (vty->ty == Tcomplex80) { + extractty = Type::tfloat80; + } + DImValue* re = new DImValue(extractty, repart); return DtoCastFloat(loc, re, to); } else if (to->ty == Tbool) {