Skip to content

Commit

Permalink
Merge pull request #3816 from 9rnsr/fix_sc
Browse files Browse the repository at this point in the history
Copying scope object should fill filedinit to NULL, due to avoid issue 11777
  • Loading branch information
yebblies authored and 9rnsr committed Jul 27, 2014
1 parent e000080 commit 615300e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
8 changes: 2 additions & 6 deletions src/class.c
Expand Up @@ -349,9 +349,7 @@ void ClassDeclaration::semantic(Scope *sc)
// Expand any tuples in baseclasses[]
for (size_t i = 0; i < baseclasses->dim; )
{
if (!scx)
scx = sc->copyExact();
scope = scx;
scope = scx ? scx : sc->copy();
scope->setNoFree();

BaseClass *b = (*baseclasses)[i];
Expand Down Expand Up @@ -1335,9 +1333,7 @@ void InterfaceDeclaration::semantic(Scope *sc)
// Expand any tuples in baseclasses[]
for (size_t i = 0; i < baseclasses->dim; )
{
if (!scx)
scx = sc->copyExact();
scope = scx;
scope = scx ? scx : sc->copy();
scope->setNoFree();

BaseClass *b = (*baseclasses)[i];
Expand Down
13 changes: 3 additions & 10 deletions src/scope.c
Expand Up @@ -90,16 +90,10 @@ Scope::Scope()
this->userAttribDecl = NULL;
}

Scope *Scope::copyExact()
Scope *Scope::copy()
{
Scope *sc = Scope::alloc();
memcpy(sc, this, sizeof(Scope));
return sc;
}

Scope *Scope::copy()
{
Scope *sc = copyExact();

/* Bugzilla 11777: The copied scope should not inherit fieldinit.
*/
Expand Down Expand Up @@ -137,10 +131,9 @@ Scope *Scope::createGlobal(Module *module)

Scope *Scope::push()
{
//printf("Scope::push()\n");
Scope *s = copyExact();
Scope *s = copy();

//printf("Scope::Scope(enclosing = %p) %p\n", enclosing, this);
//printf("Scope::push(this = %p) new = %p\n", this, s);
assert(!(flags & SCOPEfree));
s->scopesym = NULL;
s->sds = NULL;
Expand Down
1 change: 0 additions & 1 deletion src/scope.h
Expand Up @@ -118,7 +118,6 @@ struct Scope

Scope();

Scope *copyExact();
Scope *copy();

Scope *push();
Expand Down

0 comments on commit 615300e

Please sign in to comment.