Skip to content

Commit

Permalink
Fix wrong fields.dim value from test13613.
Browse files Browse the repository at this point in the history
This is a regression from fixing issue 15726, which caused gdc to ICE because it actually verifies the contents of the frontend AST are correct.
  • Loading branch information
ibuclaw authored and MartinNowak committed Mar 24, 2017
1 parent 91d9415 commit f429983
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/ddmd/aggregate.d
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
return true;

//printf("determineFields() %s, fields.dim = %d\n", toChars(), fields.dim);
fields.setDim(0);

extern (C++) static int func(Dsymbol s, void* param)
{
Expand All @@ -241,8 +242,14 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
if (v.storage_class & STCmanifest)
return 0;

auto ad = cast(AggregateDeclaration)param;

if (v._scope)
v.semantic(null);
// Note: Aggregate fields or size could have determined during v->semantic.
if (ad.sizeok != SIZEOKnone)
return 1;

if (v.aliassym)
return 0; // If this variable was really a tuple, skip it.

Expand All @@ -251,7 +258,6 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
if (!v.isField() || v.semanticRun < PASSsemanticdone)
return 1; // unresolvable forward reference

auto ad = cast(AggregateDeclaration)param;
ad.fields.push(v);

if (v.storage_class & STCref)
Expand All @@ -270,13 +276,15 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
return 0;
}

fields.setDim(0);

for (size_t i = 0; i < members.dim; i++)
{
auto s = (*members)[i];
if (s.apply(&func, cast(void*)this))
{
if (sizeok != SIZEOKnone)
return true;
return false;
}
}

if (sizeok != SIZEOKdone)
Expand Down

0 comments on commit f429983

Please sign in to comment.