From 56ddd223f9f2b5b0c7c8c1f9bb0938af70284bfe Mon Sep 17 00:00:00 2001 From: Daniel Murphy Date: Sun, 24 Nov 2013 17:33:58 +1100 Subject: [PATCH] Fix Issue 8903 - Bad code for enum array members --- src/e2ir.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/e2ir.c b/src/e2ir.c index ba2bde2ce33e..90968d62f7cb 100644 --- a/src/e2ir.c +++ b/src/e2ir.c @@ -50,6 +50,7 @@ elem *addressElem(elem *e, Type *t, bool alwaysCopy = false); elem *eval_Darray(IRState *irs, Expression *e, bool alwaysCopy = false); elem *array_toPtr(Type *t, elem *e); elem *appendDtors(IRState *irs, elem *er, size_t starti, size_t endi); +elem *ExpressionsToStaticArray(IRState *irs, Loc loc, Expressions *exps, symbol **psym); #define el_setLoc(e,loc) ((e)->Esrcpos.Sfilename = (char *)(loc).filename, \ (e)->Esrcpos.Slinnum = (loc).linnum) @@ -4832,7 +4833,6 @@ elem *tree_insert(Elems *args, size_t low, size_t high) elem *ArrayLiteralExp::toElem(IRState *irs) { elem *e; size_t dim; - elem *earg = NULL; //printf("ArrayLiteralExp::toElem() %s, type = %s\n", toChars(), type->toChars()); Type *tb = type->toBasetype(); @@ -4840,7 +4840,13 @@ elem *ArrayLiteralExp::toElem(IRState *irs) { // Convert void[n] to ubyte[n] tb = TypeSArray::makeType(loc, Type::tuns8, ((TypeSArray *)tb)->dim->toUInteger()); } - if (elements) + if (tb->ty == Tsarray && elements && elements->dim) + { + Symbol *sdata; + e = ExpressionsToStaticArray(irs, loc, elements, &sdata); + e = el_combine(e, el_ptr(sdata)); + } + else if (elements) { /* Instead of passing the initializers on the stack, allocate the * array and assign the members inline. @@ -4903,7 +4909,6 @@ elem *ArrayLiteralExp::toElem(IRState *irs) } el_setLoc(e,loc); - e = el_combine(earg, e); return e; }