Skip to content

Commit

Permalink
Merge pull request #3537 from 9rnsr/fix12719
Browse files Browse the repository at this point in the history
[REG2.066a] Issue 12719 - struct.c:705: virtual void StructDeclaration::semantic(Scope*): Assertion `parent && parent == sc->parent' failed.
  • Loading branch information
WalterBright committed May 10, 2014
2 parents d5669dc + 73028ba commit 7f05c8e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
23 changes: 7 additions & 16 deletions src/class.c
Expand Up @@ -275,6 +275,8 @@ void ClassDeclaration::semantic(Scope *sc)

if (semanticRun >= PASSsemanticdone)
return;
unsigned dprogress_save = Module::dprogress;
int errors = global.errors;

Scope *scx = NULL;
if (scope)
Expand All @@ -283,8 +285,6 @@ void ClassDeclaration::semantic(Scope *sc)
scx = scope; // save so we don't make redundant copies
scope = NULL;
}
unsigned dprogress_save = Module::dprogress;
int errors = global.errors;

if (!parent)
{
Expand Down Expand Up @@ -779,7 +779,9 @@ void ClassDeclaration::semantic(Scope *sc)
}
structsize = offset;
sizeok = SIZEOKdone;

Module::dprogress++;
semanticRun = PASSsemanticdone;

dtor = buildDtor(this, sc2);
if (FuncDeclaration *f = hasIdentityOpAssign(this, sc2))
Expand All @@ -789,15 +791,6 @@ void ClassDeclaration::semantic(Scope *sc)
}
sc2->pop();

#if 0 // Do not call until toObjfile() because of forward references
// Fill in base class vtbl[]s
for (i = 0; i < vtblInterfaces->dim; i++)
{
BaseClass *b = (*vtblInterfaces)[i];

//b->fillVtbl(this, &b->vtbl, 1);
}
#endif
//printf("-ClassDeclaration::semantic(%s), type = %p\n", toChars(), type);

if (deferred && !global.gag)
Expand All @@ -814,8 +807,6 @@ void ClassDeclaration::semantic(Scope *sc)
}
#endif
assert(type->ty != Tclass || ((TypeClass *)type)->sym == this);

semanticRun = PASSsemanticdone;
}

void ClassDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
Expand Down Expand Up @@ -1274,6 +1265,7 @@ void InterfaceDeclaration::semantic(Scope *sc)

if (semanticRun >= PASSsemanticdone)
return;
int errors = global.errors;

Scope *scx = NULL;
if (scope)
Expand All @@ -1282,7 +1274,6 @@ void InterfaceDeclaration::semantic(Scope *sc)
scx = scope; // save so we don't make redundant copies
scope = NULL;
}
int errors = global.errors;

if (!parent)
{
Expand Down Expand Up @@ -1494,6 +1485,8 @@ void InterfaceDeclaration::semantic(Scope *sc)
s->semantic(sc2);
}

semanticRun = PASSsemanticdone;

if (global.errors != errors)
{
// The type is no good.
Expand All @@ -1513,8 +1506,6 @@ void InterfaceDeclaration::semantic(Scope *sc)
}
#endif
assert(type->ty != Tclass || ((TypeClass *)type)->sym == this);

semanticRun = PASSsemanticdone;
}


Expand Down
7 changes: 3 additions & 4 deletions src/struct.c
Expand Up @@ -686,6 +686,8 @@ void StructDeclaration::semantic(Scope *sc)

if (semanticRun >= PASSsemanticdone)
return;
unsigned dprogress_save = Module::dprogress;
int errors = global.errors;

Scope *scx = NULL;
if (scope)
Expand All @@ -694,8 +696,6 @@ void StructDeclaration::semantic(Scope *sc)
scx = scope; // save so we don't make redundant copies
scope = NULL;
}
unsigned dprogress_save = Module::dprogress;
int errors = global.errors;

if (!parent)
{
Expand Down Expand Up @@ -815,6 +815,7 @@ void StructDeclaration::semantic(Scope *sc)
}

Module::dprogress++;
semanticRun = PASSsemanticdone;

//printf("-StructDeclaration::semantic(this=%p, '%s')\n", this, toChars());

Expand Down Expand Up @@ -928,8 +929,6 @@ void StructDeclaration::semantic(Scope *sc)
}
#endif
assert(type->ty != Tstruct || ((TypeStruct *)type)->sym == this);

semanticRun = PASSsemanticdone;
}

Dsymbol *StructDeclaration::search(Loc loc, Identifier *ident, int flags)
Expand Down
17 changes: 17 additions & 0 deletions test/runnable/template9.d
Expand Up @@ -3382,6 +3382,23 @@ struct S12651(T) { }

static assert(!__traits(compiles, TemplateArgsOf12651!(S12651!int, S, float)));

/******************************************/
// 12719

struct A12719
{
B12719!int b();
}

struct B12719(T)
{
A12719 a;
void m()
{
auto v = B12719!T.init;
}
}

/******************************************/

int main()
Expand Down

0 comments on commit 7f05c8e

Please sign in to comment.