From 9aad1ca6d144f772cc4e3901d5c2481f6e1501f3 Mon Sep 17 00:00:00 2001 From: Alexey Prokhin Date: Thu, 30 Dec 2010 14:04:40 +0300 Subject: [PATCH] Fixed casting of the complex types to the imaginary types --- gen/complex.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gen/complex.cpp b/gen/complex.cpp index 35faf991..ea12efd4 100644 --- a/gen/complex.cpp +++ b/gen/complex.cpp @@ -457,7 +457,15 @@ DValue* DtoCastComplex(Loc& loc, DValue* val, Type* _to) // FIXME: this loads both values, even when we only need one LLValue* v = val->getRVal(); LLValue* impart = gIR->ir->CreateExtractValue(v, 1, ".im_part"); - DImValue* im = new DImValue(to, impart); + Type *extractty; + if (vty->ty == Tcomplex32) { + extractty = Type::timaginary32; + } else if (vty->ty == Tcomplex64) { + extractty = Type::timaginary64; + } else if (vty->ty == Tcomplex80) { + extractty = Type::timaginary80; + } + DImValue* im = new DImValue(extractty, impart); return DtoCastFloat(loc, im, to); } else if (to->ty == Tbool) {