Skip to content

Commit

Permalink
LabelStatement::flatten should reuse 'this' for the call after sema…
Browse files Browse the repository at this point in the history
…ntic.
  • Loading branch information
9rnsr committed Dec 1, 2013
1 parent 23a8acd commit aba7605
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/statement.c
Expand Up @@ -5003,7 +5003,8 @@ Statements *DebugStatement::flatten(Scope *sc)
{
Statements *a = statement ? statement->flatten(sc) : NULL;
if (a)
{ for (size_t i = 0; i < a->dim; i++)
{
for (size_t i = 0; i < a->dim; i++)
{ Statement *s = (*a)[i];

s = new DebugStatement(loc, s);
Expand Down Expand Up @@ -5149,14 +5150,14 @@ Statement *LabelStatement::syntaxCopy()
}

Statement *LabelStatement::semantic(Scope *sc)
{ LabelDsymbol *ls;
{
FuncDeclaration *fd = sc->parent->isFuncDeclaration();

this->lastVar = sc->lastVar;
//printf("LabelStatement::semantic()\n");
ident = fixupLabelName(sc, ident);

ls = fd->searchLabel(ident);
LabelDsymbol *ls = fd->searchLabel(ident);
if (ls->statement)
{
error("Label '%s' already defined", ls->toChars());
Expand Down Expand Up @@ -5194,10 +5195,10 @@ Statements *LabelStatement::flatten(Scope *sc)
{
a->push(new ExpStatement(loc, (Expression *)NULL));
}
Statement *s = (*a)[0];

s = new LabelStatement(loc, ident, s);
(*a)[0] = s;
// reuse 'this' LabelStatement
this->statement = (*a)[0];
(*a)[0] = this;
}
}

Expand Down

0 comments on commit aba7605

Please sign in to comment.