mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00
fix Issue 22933 - importC: goto skips declaration of variable (#13913)
This commit is contained in:
parent
aea95087f8
commit
9aa405e445
4 changed files with 15 additions and 3 deletions
|
@ -1230,7 +1230,7 @@ private extern(C++) final class Semantic3Visitor : Visitor
|
|||
}
|
||||
|
||||
// Fix up forward-referenced gotos
|
||||
if (funcdecl.gotos)
|
||||
if (funcdecl.gotos && !funcdecl.isCsymbol())
|
||||
{
|
||||
for (size_t i = 0; i < funcdecl.gotos.dim; ++i)
|
||||
{
|
||||
|
|
|
@ -1761,6 +1761,9 @@ extern (C++) final class GotoStatement : Statement
|
|||
return new GotoStatement(loc, ident);
|
||||
}
|
||||
|
||||
/**************
|
||||
* Returns: true for error
|
||||
*/
|
||||
extern (D) bool checkLabel()
|
||||
{
|
||||
if (!label.statement)
|
||||
|
|
|
@ -2369,7 +2369,7 @@ package (dmd) extern (C++) final class StatementSemanticVisitor : Visitor
|
|||
ss._body = cs;
|
||||
}
|
||||
|
||||
if (ss.checkLabel())
|
||||
if (!(sc.flags & SCOPE.Cfile) && ss.checkLabel())
|
||||
{
|
||||
sc.pop();
|
||||
return setError();
|
||||
|
@ -3844,7 +3844,7 @@ package (dmd) extern (C++) final class StatementSemanticVisitor : Visitor
|
|||
fd.gotos = new GotoStatements();
|
||||
fd.gotos.push(gs);
|
||||
}
|
||||
else if (gs.checkLabel())
|
||||
else if (!(sc.flags & SCOPE.Cfile) && gs.checkLabel())
|
||||
return setError();
|
||||
|
||||
result = gs;
|
||||
|
|
9
test/compilable/test22933.c
Normal file
9
test/compilable/test22933.c
Normal file
|
@ -0,0 +1,9 @@
|
|||
// https://issues.dlang.org/show_bug.cgi?id=22933
|
||||
|
||||
void fn()
|
||||
{
|
||||
goto L;
|
||||
int x = 1;
|
||||
L:
|
||||
return;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue