mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 21:21:48 +03:00
fix Issue 23586 - DMD forgets a variable was just declared
This commit is contained in:
parent
c5d192dfa3
commit
6b2c13a9eb
3 changed files with 40 additions and 0 deletions
|
@ -5720,6 +5720,8 @@ LagainStc:
|
|||
s = null;
|
||||
else if (token.value == TOK.leftCurly)
|
||||
s = parseStatement(ParseStatementFlags.curly | ParseStatementFlags.scope_);
|
||||
else if (flags & ParseStatementFlags.curlyScope)
|
||||
s = parseStatement(ParseStatementFlags.semiOk | ParseStatementFlags.curlyScope);
|
||||
else
|
||||
s = parseStatement(ParseStatementFlags.semiOk);
|
||||
s = new AST.LabelStatement(loc, ident, s);
|
||||
|
|
|
@ -323,6 +323,10 @@ extern (C++) abstract class Statement : ASTNode
|
|||
override void visit(DefaultStatement s)
|
||||
{
|
||||
}
|
||||
|
||||
override void visit(LabelStatement s)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
scope HasCode hc = new HasCode();
|
||||
|
|
34
compiler/test/compilable/test23586.d
Normal file
34
compiler/test/compilable/test23586.d
Normal file
|
@ -0,0 +1,34 @@
|
|||
// https://issues.dlang.org/show_bug.cgi?id=23586
|
||||
|
||||
int test23686a(int x)
|
||||
{
|
||||
switch(x)
|
||||
{
|
||||
case 0:
|
||||
goto Bar;
|
||||
|
||||
Bar:
|
||||
default:
|
||||
auto y = 6;
|
||||
return y;
|
||||
}
|
||||
}
|
||||
|
||||
int test23686b(int x)
|
||||
{
|
||||
switch(x)
|
||||
{
|
||||
case 0:
|
||||
Bar:
|
||||
case 1:
|
||||
case 2:
|
||||
auto y = 7;
|
||||
return y;
|
||||
|
||||
default:
|
||||
goto Bar;
|
||||
}
|
||||
}
|
||||
|
||||
static assert(test23686a(0) == 6);
|
||||
static assert(test23686b(3) == 7);
|
Loading…
Add table
Add a link
Reference in a new issue