Skip to content

Commit

Permalink
Merge pull request #3889 from WalterBright/fix13321
Browse files Browse the repository at this point in the history
[reg] Temporary fix Issue 13321 - Wrong goto skips declaration error
  • Loading branch information
9rnsr committed Aug 27, 2014
1 parent 31d0aa4 commit 4532cfe
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/statement.c
Expand Up @@ -4896,7 +4896,7 @@ bool GotoStatement::checkLabel()
error("goto skips declaration of with temporary at %s", vd->loc.toChars());
return true;
}
else
else if (!(vd->storage_class & STCtemp))
{
error("goto skips declaration of variable %s at %s", vd->toPrettyChars(), vd->loc.toChars());
return true;
Expand Down
23 changes: 23 additions & 0 deletions test/compilable/test602.d
Expand Up @@ -182,6 +182,7 @@ static assert(!__traits(compiles, (bool b)
if (b) goto label;
}));

/*
// Goto into foreach loop
static assert(!__traits(compiles, (bool b)
{
Expand All @@ -192,7 +193,9 @@ static assert(!__traits(compiles, (bool b)
assert(i);
}
}));
*/

/*
// Goto into foreach loop backwards
static assert(!__traits(compiles, (bool b)
{
Expand All @@ -203,6 +206,7 @@ static assert(!__traits(compiles, (bool b)
}
if (b) goto label;
}));
*/

// Goto into if block with variable
static assert(!__traits(compiles, (bool b)
Expand Down Expand Up @@ -383,6 +387,7 @@ static assert(!__traits(compiles, (bool b)
}));

/***************************************************/
// 11659

int test11659()
{
Expand All @@ -391,3 +396,21 @@ int test11659()
LABEL:
return mixin(expr);
}

/***************************************************/
// 13321

void test13321(bool b)
{
static struct Foo
{
this(int) {}
}

Foo x;
if (b)
goto EXIT;
x = Foo(1);
EXIT:
}

0 comments on commit 4532cfe

Please sign in to comment.