From bba1994b05a0536556eef9ea0b0331b405556b87 Mon Sep 17 00:00:00 2001 From: Tomas Lindquist Olsen Date: Thu, 11 Sep 2008 21:10:15 +0200 Subject: [PATCH] Fixed a few mini tests issues. Added 'darwin' and 'Posix' as versions user can't set. Fixed #80 . --- dmd/cond.c | 2 +- gen/toir.cpp | 14 +++++++++++--- tests/mini/arrays16.d | 2 +- tests/mini/arrays17.d | 2 +- tests/mini/arrays18.d | 2 +- tests/mini/arrays19.d | 9 +++++++++ tests/mini/arrays20.d | 23 +++++++++++++++++++++++ tests/mini/complex5.d | 13 +++++++++++++ 8 files changed, 60 insertions(+), 7 deletions(-) create mode 100644 tests/mini/arrays19.d create mode 100644 tests/mini/arrays20.d create mode 100644 tests/mini/complex5.d diff --git a/dmd/cond.c b/dmd/cond.c index 713638c8..d605cdf6 100644 --- a/dmd/cond.c +++ b/dmd/cond.c @@ -130,7 +130,7 @@ void VersionCondition::checkPredefined(Loc loc, char *ident) "DigitalMars", "LLVM", "LLVMDC", "LLVM64", "X86", "X86_64", "PPC", "PPC64", "Windows", "Win32", "Win64", - "linux", + "linux", "darwin", "Posix", "LittleEndian", "BigEndian", "all", "none", diff --git a/gen/toir.cpp b/gen/toir.cpp index 52dacfda..0b903df7 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -2156,12 +2156,20 @@ DValue* ArrayLiteralExp::toElem(IRState* p) Logger::cout() << (dyn?"dynamic":"static") << " array literal with length " << len << " of D type: '" << arrayType->toChars() << "' has llvm type: '" << *llType << "'\n"; // llvm storage type - const LLType* llStoType = LLArrayType::get(DtoType(elemType), len); + const LLType* llElemType = DtoTypeNotVoid(elemType); + const LLType* llStoType = LLArrayType::get(llElemType, len); Logger::cout() << "llvm storage type: '" << *llStoType << "'\n"; + // don't allocate storage for zero length dynamic array literals + if (dyn && len == 0) + { + // dmd seems to just make them null... + return new DSliceValue(type, DtoConstSize_t(0), getNullPtr(getPtrToType(llElemType))); + } + // dst pointer - LLValue* dstMem = 0; - dstMem = DtoAlloca(llStoType, "arrayliteral"); + // FIXME: dynamic array literals should be allocated with the GC + LLValue* dstMem = DtoAlloca(llStoType, "arrayliteral"); // store elements for (size_t i=0; i 2.9999 && c.re < 3.0001); + assert(c.im > 1.9999i && c.im < 2.0001); +}