Skip to content

Commit

Permalink
Backport fix for DMD Issue 15607
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuclaw committed Jul 23, 2017
1 parent 8c8191f commit a2c639b
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/init.c
Expand Up @@ -622,6 +622,35 @@ Expression *ArrayInitializer::toExpression(Type *tx)
}
}

/* Expand any static array initializers that are a single expression
* into an array of them
*/
if (t)
{
Type *tn = t->nextOf()->toBasetype();
if (tn->ty == Tsarray)
{
size_t dim = ((TypeSArray *)tn)->dim->toInteger();
Type *te = tn->nextOf()->toBasetype();
for (size_t i = 0; i < elements->dim; i++)
{
Expression *e = (*elements)[i];
if (te->equals(e->type))
{
Expressions *elements2 = new Expressions();
elements2->setDim(dim);
for (size_t j = 0; j < dim; j++)
(*elements2)[j] = e;
e = new ArrayLiteralExp(e->loc, elements2);
e->type = tn;
(*elements)[i] = e;
}
}
}
}

/* If any elements are errors, then the whole thing is an error
*/
for (size_t i = 0; i < edim; i++)
{
Expression *e = (*elements)[i];
Expand Down

0 comments on commit a2c639b

Please sign in to comment.