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:
The Dlang Bot 2019-07-31 13:51:10 +02:00 committed by GitHub
commit 43c4ce36cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View file

@ -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; }

View file

@ -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));
}
}