Skip to content

Commit

Permalink
Merge pull request #2611 from 9rnsr/fix11105
Browse files Browse the repository at this point in the history
[REG2.064a] Issue 11105 - Error on struct with multidimentional static array initialization from its element
  • Loading branch information
WalterBright committed Oct 3, 2013
2 parents 6c8f9ff + d4638f1 commit efcd62c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/expression.c
Original file line number Diff line number Diff line change
Expand Up @@ -4695,13 +4695,12 @@ Expression *StructLiteralExp::semantic(Scope *sc)
if (stype)
telem = telem->addMod(stype->mod);
Type *origType = telem;
if (!e->implicitConvTo(telem))
while (!e->implicitConvTo(telem) && telem->toBasetype()->ty == Tsarray)
{
/* Static array initialization, as in:
* T[3][5] = e;
*/
while (telem->toBasetype()->ty == Tsarray)
telem = telem->toBasetype()->nextOf();
telem = telem->toBasetype()->nextOf();
}

if (!e->implicitConvTo(telem))
Expand Down
14 changes: 14 additions & 0 deletions test/runnable/structlit.d
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,19 @@ const date9775c2 = Date9775(2012, 12, 21);
enum Date9775 date9775e1 = Date9775(2012, 12, 21);
enum date9775e2 = Date9775(2012, 12, 21);

/********************************************/
// 11105

struct S11105
{
int[2][1] a21;
}

void test11105()
{
S11105 s = S11105([1, 2]);
}

/********************************************/
// 11147

Expand Down Expand Up @@ -1072,6 +1085,7 @@ int main()
test9116();
test9293();
test9566();
test11105();
test11147();

printf("Success\n");
Expand Down

0 comments on commit efcd62c

Please sign in to comment.