From 015cf202e18e08f1a2e65b1832eb13311b28af07 Mon Sep 17 00:00:00 2001 From: Kai Nacke Date: Tue, 12 Nov 2013 08:23:06 +0100 Subject: [PATCH] Fix cast problem with implicit constructors. --- dmd2/expression.c | 3 +++ gen/toir.cpp | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/dmd2/expression.c b/dmd2/expression.c index 240e1261..f0631e1e 100644 --- a/dmd2/expression.c +++ b/dmd2/expression.c @@ -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); } } diff --git a/gen/toir.cpp b/gen/toir.cpp index f5e3675d..d2196212 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -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))