mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00
Merge pull request #10248 from WalterBright/gotos
add isGotoStatement() merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
This commit is contained in:
commit
43c4ce36cc
2 changed files with 5 additions and 5 deletions
|
@ -425,6 +425,7 @@ extern (C++) abstract class Statement : ASTNode
|
|||
inout(CaseStatement) isCaseStatement() { return stmt == STMT.Case ? cast(typeof(return))this : null; }
|
||||
inout(DefaultStatement) isDefaultStatement() { return stmt == STMT.Default ? cast(typeof(return))this : null; }
|
||||
inout(LabelStatement) isLabelStatement() { return stmt == STMT.Label ? cast(typeof(return))this : null; }
|
||||
inout(GotoStatement) isGotoStatement() { return stmt == STMT.Goto ? cast(typeof(return))this : null; }
|
||||
inout(GotoDefaultStatement) isGotoDefaultStatement() { return stmt == STMT.GotoDefault ? cast(typeof(return))this : null; }
|
||||
inout(GotoCaseStatement) isGotoCaseStatement() { return stmt == STMT.GotoCase ? cast(typeof(return))this : null; }
|
||||
inout(BreakStatement) isBreakStatement() { return stmt == STMT.Break ? cast(typeof(return))this : null; }
|
||||
|
|
|
@ -1178,7 +1178,7 @@ private extern (C++) final class StatementSemanticVisitor : Visitor
|
|||
}
|
||||
}
|
||||
|
||||
Statement s = fs;
|
||||
Statement s;
|
||||
switch (tab.ty)
|
||||
{
|
||||
case Tarray:
|
||||
|
@ -1679,15 +1679,14 @@ private extern (C++) final class StatementSemanticVisitor : Visitor
|
|||
goto case Terror;
|
||||
|
||||
// Resolve any forward referenced goto's
|
||||
foreach (i; 0 .. fs.gotos.dim)
|
||||
foreach (ScopeStatement ss; *fs.gotos)
|
||||
{
|
||||
GotoStatement gs = cast(GotoStatement)(*fs.gotos)[i].statement;
|
||||
GotoStatement gs = ss.statement.isGotoStatement();
|
||||
if (!gs.label.statement)
|
||||
{
|
||||
// 'Promote' it to this scope, and replace with a return
|
||||
fs.cases.push(gs);
|
||||
s = new ReturnStatement(Loc.initial, new IntegerExp(fs.cases.dim + 1));
|
||||
(*fs.gotos)[i].statement = s;
|
||||
ss.statement = new ReturnStatement(Loc.initial, new IntegerExp(fs.cases.dim + 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue