Mercurial > projects > ldc
changeset 587:23538d0f0d5b
Fixed a few mini tests issues.
Added 'darwin' and 'Posix' as versions user can't set.
Fixed #80 .
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Thu, 11 Sep 2008 21:10:15 +0200 |
parents | 192b82878b78 |
children | 870652a9af23 |
files | dmd/cond.c gen/toir.cpp tests/mini/arrays16.d tests/mini/arrays17.d tests/mini/arrays18.d tests/mini/arrays19.d tests/mini/arrays20.d tests/mini/complex5.d |
diffstat | 8 files changed, 60 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/dmd/cond.c Wed Sep 10 12:33:33 2008 -0700 +++ b/dmd/cond.c Thu Sep 11 21:10:15 2008 +0200 @@ -130,7 +130,7 @@ "DigitalMars", "LLVM", "LLVMDC", "LLVM64", "X86", "X86_64", "PPC", "PPC64", "Windows", "Win32", "Win64", - "linux", + "linux", "darwin", "Posix", "LittleEndian", "BigEndian", "all", "none",
--- a/gen/toir.cpp Wed Sep 10 12:33:33 2008 -0700 +++ b/gen/toir.cpp Thu Sep 11 21:10:15 2008 +0200 @@ -2156,12 +2156,20 @@ 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<len; ++i)
--- a/tests/mini/arrays16.d Wed Sep 10 12:33:33 2008 -0700 +++ b/tests/mini/arrays16.d Thu Sep 11 21:10:15 2008 +0200 @@ -1,4 +1,4 @@ -module tangotests.arrays2; +module mini.arrays16; void main() {
--- a/tests/mini/arrays17.d Wed Sep 10 12:33:33 2008 -0700 +++ b/tests/mini/arrays17.d Thu Sep 11 21:10:15 2008 +0200 @@ -1,4 +1,4 @@ -module tangotests.arrays3; +module mini.arrays17; void main() {
--- a/tests/mini/arrays18.d Wed Sep 10 12:33:33 2008 -0700 +++ b/tests/mini/arrays18.d Thu Sep 11 21:10:15 2008 +0200 @@ -1,4 +1,4 @@ -module tangotests.arrays4; +module mini.arrays18; struct Str { int a,b; } void main() {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/mini/arrays19.d Thu Sep 11 21:10:15 2008 +0200 @@ -0,0 +1,9 @@ +module mini.arrays19; + +extern(C) int printf(char*, ...); + +void main() +{ + bool var = ([] is null); + assert(var); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/mini/arrays20.d Thu Sep 11 21:10:15 2008 +0200 @@ -0,0 +1,23 @@ +module mini.arrays20; + +int[] foo() +{ + return [2,4,6]; +} + +int[] bar() +{ + return [1,3,5]; +} + +void main() +{ + auto a = foo(); + auto b = bar(); + assert(b[0] == 1); + assert(a[0] == 2); + assert(b[1] == 3); + assert(a[1] == 4); + assert(b[2] == 5); + assert(a[2] == 6); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/mini/complex5.d Thu Sep 11 21:10:15 2008 +0200 @@ -0,0 +1,13 @@ +module complex5; + +void main() +{ + cfloat c = 3+2i; + foo(c); +} + +void foo(cfloat c) +{ + assert(c.re > 2.9999 && c.re < 3.0001); + assert(c.im > 1.9999i && c.im < 2.0001); +}