Skip to content

Commit

Permalink
Fix Issue 8903 - Bad code for enum array members
Browse files Browse the repository at this point in the history
  • Loading branch information
yebblies committed Nov 24, 2013
1 parent 69dcaa9 commit 56ddd22
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 @@ -4832,15 +4833,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 @@ -4903,7 +4909,6 @@ elem *ArrayLiteralExp::toElem(IRState *irs)
}

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

Expand Down

0 comments on commit 56ddd22

Please sign in to comment.