From 280be5ef8e095525ddc4890829f8c39c37fbec71 Mon Sep 17 00:00:00 2001 From: Tomas Lindquist Olsen Date: Tue, 3 Feb 2009 23:48:47 +0100 Subject: [PATCH] Fixed dstress/run/a/array_initialization_17_A.d regression. default initialized static array elements in a constant static array initializer was getting incorrect values. Fixed minor version problem in mini/naked_asm4.d test case. --- gen/arrays.cpp | 2 +- gen/toir.cpp | 2 ++ tests/mini/naked_asm4.d | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gen/arrays.cpp b/gen/arrays.cpp index c310abee..43645f73 100644 --- a/gen/arrays.cpp +++ b/gen/arrays.cpp @@ -290,7 +290,7 @@ LLConstant* DtoConstArrayInitializer(ArrayInitializer* arrinit) // fill out any null entries still left with default values // element default initializer - LLConstant* defelem = elemty->defaultInit(arrinit->loc)->toConstElem(gIR); + LLConstant* defelem = DtoConstExpInit(arrinit->loc, elemty, elemty->defaultInit(arrinit->loc)); bool mismatch2 = (defelem->getType() != llelemty); for (size_t i = 0; i < arrlen; i++) diff --git a/gen/toir.cpp b/gen/toir.cpp index b3b10392..7cffd4cc 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -1632,6 +1632,8 @@ DValue* NewExp::toElem(IRState* p) DVarValue tmpvar(newtype, mem); // default initialize + // FIXME: should this use DtoConstExpInit instead ? + // or is static arrays the only troublemaker? Expression* exp = newtype->defaultInit(loc); DValue* iv = exp->toElem(gIR); DtoAssign(loc, &tmpvar, iv); diff --git a/tests/mini/naked_asm4.d b/tests/mini/naked_asm4.d index 5303dc66..116a92c9 100644 --- a/tests/mini/naked_asm4.d +++ b/tests/mini/naked_asm4.d @@ -8,7 +8,7 @@ void foo() hlt; pass: ret; } - version(X86_64) + else version(X86_64) asm { naked;