Skip to content

Commit

Permalink
Merge pull request #5693 from WalterBright/fix15323
Browse files Browse the repository at this point in the history
fix Issue 15323 - Module.members and .deferred3 should use data struc…
  • Loading branch information
andralex committed Apr 23, 2016
2 parents 84d9f10 + cef279d commit d57ca4c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/dtemplate.d
Expand Up @@ -5932,6 +5932,8 @@ public:

TemplateInstances* deferred;

Module memberOf; // if !null, then this TemplateInstance appears in memberOf.members[]

// Used to determine the instance needs code generation.
// Note that these are inaccurate until semantic analysis phase completed.
TemplateInstance tinst; // enclosing template instance
Expand Down Expand Up @@ -6501,6 +6503,7 @@ public:
// should be able to remove it without messing other indices up.
assert((*target_symbol_list)[target_symbol_list_idx] == this);
target_symbol_list.remove(target_symbol_list_idx);
memberOf = null; // no longer a member
}
semanticRun = PASSinit;
inst = null;
Expand Down Expand Up @@ -8008,22 +8011,26 @@ public:
}
//printf("\t--> mi = %s\n", mi.toPrettyChars());

Dsymbols* a = mi.members;
for (size_t i = 0; 1; i++)
if (memberOf is mi) // already a member
{
if (i == a.dim)
{
a.push(this);
if (mi.semanticRun >= PASSsemantic3done && mi.isRoot())
Module.addDeferredSemantic3(this);
break;
}
if (this == (*a)[i]) // if already in Array
debug // make sure it really is a member
{
a = null;
break;
auto a = mi.members;
for (size_t i = 0; 1; ++i)
{
assert(i != a.dim);
if (this == (*a)[i])
break;
}
}
return null;
}

Dsymbols* a = mi.members;
a.push(this);
memberOf = mi;
if (mi.semanticRun >= PASSsemantic3done && mi.isRoot())
Module.addDeferredSemantic3(this);
return a;
}

Expand Down
2 changes: 2 additions & 0 deletions src/template.h
Expand Up @@ -317,6 +317,8 @@ class TemplateInstance : public ScopeDsymbol

TemplateInstances* deferred;

Module *memberOf; // if !null, then this TemplateInstance appears in memberOf.members[]

// Used to determine the instance needs code generation.
// Note that these are inaccurate until semantic analysis phase completed.
TemplateInstance *tinst; // enclosing template instance
Expand Down

0 comments on commit d57ca4c

Please sign in to comment.