Skip to content

Commit

Permalink
fix Issue 11659 - false positive goto skips initialization of variabl…
Browse files Browse the repository at this point in the history
…e error (skipping enum initialization)
  • Loading branch information
9rnsr committed Dec 3, 2013
1 parent ddb5e65 commit 05beebe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/statement.c
Expand Up @@ -5124,8 +5124,11 @@ bool GotoStatement::checkLabel()
return true;
}

VarDeclaration *last = lastVar;
VarDeclaration *vd = label->statement->lastVar;
if (!vd || vd->isDataseg() || (vd->storage_class & STCmanifest))
return false;

VarDeclaration *last = lastVar;
while (last && last != vd)
last = last->lastVar;
if (last == vd)
Expand Down
10 changes: 10 additions & 0 deletions test/compilable/test602.d
Expand Up @@ -381,3 +381,13 @@ static assert(!__traits(compiles, (bool b)
if (b)
goto label;
}));

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

int test11659()
{
goto LABEL;
enum expr = "0";
LABEL:
return mixin(expr);
}

0 comments on commit 05beebe

Please sign in to comment.