From 7743f564505e7fa405ed90170e53787f39dc5e58 Mon Sep 17 00:00:00 2001 From: Kai Nacke Date: Sun, 10 Nov 2013 20:34:48 +0100 Subject: [PATCH] Fix for the tuple assignment error in test aliasthis.d The DMD front end uses a hack to avoid a "has no effect" error. This hack must be recognised by LDC, too. --- gen/llvmhelpers.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/gen/llvmhelpers.cpp b/gen/llvmhelpers.cpp index 0cd46608..78cba750 100644 --- a/gen/llvmhelpers.cpp +++ b/gen/llvmhelpers.cpp @@ -571,14 +571,22 @@ DValue* DtoCastInt(Loc& loc, DValue* val, Type* _to) Type* from = val->getType()->toBasetype(); assert(from->isintegral()); - size_t fromsz = from->size(); - size_t tosz = to->size(); - LLValue* rval = val->getRVal(); if (rval->getType() == tolltype) { return new DImValue(_to, rval); } + // Check for special DMD hack to avoid "has no effect" error. + // See expression.c, method AssignExp::semantic(), around line 11499 + llvm::ConstantInt* isConstInt = isaConstantInt(rval); + if (from == Type::tint32 && to == Type::tvoid && isConstInt->isNullValue()) + { + return val; + } + + size_t fromsz = from->size(); + size_t tosz = to->size(); + if (to->ty == Tbool) { LLValue* zero = LLConstantInt::get(rval->getType(), 0, false); rval = gIR->ir->CreateICmpNE(rval, zero, "tmp");