Skip to content

Commit

Permalink
fix Issue 11622 - Assertion failure in totym(), glue.c, line 1288
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed May 14, 2014
1 parent d73783b commit ecc34fc
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
20 changes: 20 additions & 0 deletions src/class.c
Expand Up @@ -278,6 +278,8 @@ void ClassDeclaration::semantic(Scope *sc)
unsigned dprogress_save = Module::dprogress;
int errors = global.errors;

//printf("+ClassDeclaration::semantic(%s), type = %p, sizeok = %d, this = %p\n", toChars(), type, sizeok, this);

Scope *scx = NULL;
if (scope)
{
Expand Down Expand Up @@ -352,7 +354,9 @@ void ClassDeclaration::semantic(Scope *sc)
scope->setNoFree();

BaseClass *b = (*baseclasses)[i];
//printf("+ %s [%d] b->type = %s\n", toChars(), i, b->type->toChars());
b->type = b->type->semantic(loc, sc);
//printf("- %s [%d] b->type = %s\n", toChars(), i, b->type->toChars());

scope = NULL;

Expand All @@ -374,6 +378,14 @@ void ClassDeclaration::semantic(Scope *sc)
i++;
}

if (doAncestorsSemantic == SemanticDone)
{
//printf("%s already semantic analyzed, semanticRun = %d\n", toChars(), semanticRun);
if (semanticRun >= PASSsemanticdone)
return;
goto Lancestorsdone;
}

// See if there's a base class as first in baseclasses[]
if (baseclasses->dim)
{
Expand Down Expand Up @@ -489,6 +501,7 @@ void ClassDeclaration::semantic(Scope *sc)
scope = scx ? scx : sc->copy();
scope->setNoFree();
scope->module->addDeferredSemantic(this);
//printf("\tL%d semantic('%s') failed due to forward references\n", __LINE__, toChars());
return;
}
doAncestorsSemantic = SemanticDone;
Expand Down Expand Up @@ -542,6 +555,7 @@ void ClassDeclaration::semantic(Scope *sc)
com = true;
}
}
Lancestorsdone:

if (!members) // if opaque declaration
{
Expand All @@ -566,6 +580,7 @@ void ClassDeclaration::semantic(Scope *sc)
if (tc->sym->scope)
tc->sym->scope->module->addDeferredSemantic(tc->sym);
scope->module->addDeferredSemantic(this);
//printf("\tL%d semantic('%s') failed due to forward references\n", __LINE__, toChars());
return;
}
}
Expand Down Expand Up @@ -703,6 +718,9 @@ void ClassDeclaration::semantic(Scope *sc)
{
// The type is no good.
type = Type::terror;
this->errors = true;
if (deferred)
deferred->errors = true;
}

if (sizeok == SIZEOKfwd) // failed due to forward references
Expand Down Expand Up @@ -838,6 +856,8 @@ void ClassDeclaration::semantic(Scope *sc)
}
#endif
assert(type->ty != Tclass || ((TypeClass *)type)->sym == this);

//printf("-ClassDeclaration::semantic(%s), type = %p, sizeok = %d, this = %p\n", toChars(), type, sizeok, this);
}

void ClassDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
Expand Down
6 changes: 4 additions & 2 deletions src/struct.c
Expand Up @@ -191,7 +191,7 @@ void AggregateDeclaration::setScope(Scope *sc)

void AggregateDeclaration::semantic2(Scope *sc)
{
//printf("AggregateDeclaration::semantic2(%s)\n", toChars());
//printf("AggregateDeclaration::semantic2(%s) type = %s, errors = %d\n", toChars(), type->toChars(), errors);
if (!members)
return;

Expand Down Expand Up @@ -223,7 +223,7 @@ void AggregateDeclaration::semantic2(Scope *sc)

void AggregateDeclaration::semantic3(Scope *sc)
{
//printf("AggregateDeclaration::semantic3(%s)\n", toChars());
//printf("AggregateDeclaration::semantic3(%s) type = %s, errors = %d\n", toChars(), type->toChars(), errors);
if (!members)
return;

Expand Down Expand Up @@ -922,6 +922,8 @@ void StructDeclaration::semantic(Scope *sc)
// The type is no good.
type = Type::terror;
this->errors = true;
if (deferred)
deferred->errors = true;
}

if (deferred && !global.gag)
Expand Down
19 changes: 19 additions & 0 deletions test/compilable/compile1.d
Expand Up @@ -606,6 +606,25 @@ static assert(!__traits(compiles, {
class C : A12555!C { }
}));

/***************************************************/
// 11622

class A11622(T)
{
B11622!T foo()
{
return new B11622!T;
}
}

class B11622(T) : T
{
}

static assert(!__traits(compiles, {
class C : A11622!C { }
}));

/***************************************************/
// 12688

Expand Down

0 comments on commit ecc34fc

Please sign in to comment.