Skip to content

Commit

Permalink
Merge pull request #2870 from yebblies/issue8903
Browse files Browse the repository at this point in the history
Issue 8903 - Bad code for enum array members
  • Loading branch information
yebblies committed Dec 10, 2013
2 parents 7fe5f32 + 56ddd22 commit 5e937c3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/e2ir.c
Expand Up @@ -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)
Expand Down Expand Up @@ -4852,15 +4853,20 @@ 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();
if (tb->ty == Tsarray && tb->nextOf()->toBasetype()->ty == Tvoid)
{ // 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.
Expand Down Expand Up @@ -4923,7 +4929,6 @@ elem *ArrayLiteralExp::toElem(IRState *irs)
}

el_setLoc(e,loc);
e = el_combine(earg, e);
return e;
}

Expand Down

0 comments on commit 5e937c3

Please sign in to comment.