Skip to content

Commit

Permalink
[reg] Temporary fix Issue 13321 - Wrong goto skips declaration error
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Aug 23, 2014
1 parent 7f28fa6 commit 1bfe1c7
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 @@ -4907,7 +4907,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 1bfe1c7

Please sign in to comment.