Skip to content

Commit

Permalink
[expressionsem.d] use nested function instead of goto
Browse files Browse the repository at this point in the history
  • Loading branch information
thewilsonator committed Oct 5, 2024
1 parent 4d91765 commit 645db4e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions compiler/src/dmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -4113,6 +4113,11 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
ClassDeclaration cd;
Dsymbol s;

void err()
{
error(e.loc, "`super` is only allowed in non-static class member functions");
result = ErrorExp.get();
}
/* Special case for typeof(this) and typeof(super) since both
* should work even if they are not inside a non-static member function
*/
Expand Down Expand Up @@ -4142,7 +4147,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
}
}
if (!fd)
goto Lerr;
return err();

e.var = fd.vthis;
assert(e.var && e.var.parent);
Expand All @@ -4154,7 +4159,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
cd = s.isClassDeclaration();
//printf("parent is %s %s\n", fd.toParent().kind(), fd.toParent().toChars());
if (!cd)
goto Lerr;
return err();
if (!cd.baseClass)
{
error(e.loc, "no base class for `%s`", cd.toChars());
Expand All @@ -4170,11 +4175,6 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
return setError();

result = e;
return;

Lerr:
error(e.loc, "`super` is only allowed in non-static class member functions");
result = ErrorExp.get();
}

override void visit(NullExp e)
Expand Down

0 comments on commit 645db4e

Please sign in to comment.