fixes #1511
This commit is contained in:
parent
201a08e9a5
commit
e093f45756
1 changed files with 17 additions and 14 deletions
|
|
@ -22,21 +22,24 @@ proc semDiscard(c: PContext, n: PNode): PNode =
|
||||||
proc semBreakOrContinue(c: PContext, n: PNode): PNode =
|
proc semBreakOrContinue(c: PContext, n: PNode): PNode =
|
||||||
result = n
|
result = n
|
||||||
checkSonsLen(n, 1)
|
checkSonsLen(n, 1)
|
||||||
if n.sons[0].kind != nkEmpty:
|
if n.sons[0].kind != nkEmpty:
|
||||||
var s: PSym
|
if n.kind != nkContinueStmt:
|
||||||
case n.sons[0].kind
|
var s: PSym
|
||||||
of nkIdent: s = lookUp(c, n.sons[0])
|
case n.sons[0].kind
|
||||||
of nkSym: s = n.sons[0].sym
|
of nkIdent: s = lookUp(c, n.sons[0])
|
||||||
else: illFormedAst(n)
|
of nkSym: s = n.sons[0].sym
|
||||||
if s.kind == skLabel and s.owner.id == c.p.owner.id:
|
else: illFormedAst(n)
|
||||||
var x = newSymNode(s)
|
if s.kind == skLabel and s.owner.id == c.p.owner.id:
|
||||||
x.info = n.info
|
var x = newSymNode(s)
|
||||||
incl(s.flags, sfUsed)
|
x.info = n.info
|
||||||
n.sons[0] = x
|
incl(s.flags, sfUsed)
|
||||||
suggestSym(x.info, s)
|
n.sons[0] = x
|
||||||
|
suggestSym(x.info, s)
|
||||||
|
else:
|
||||||
|
localError(n.info, errInvalidControlFlowX, s.name.s)
|
||||||
else:
|
else:
|
||||||
localError(n.info, errInvalidControlFlowX, s.name.s)
|
localError(n.info, errGenerated, "'continue' cannot have a label")
|
||||||
elif (c.p.nestedLoopCounter <= 0) and (c.p.nestedBlockCounter <= 0):
|
elif (c.p.nestedLoopCounter <= 0) and (c.p.nestedBlockCounter <= 0):
|
||||||
localError(n.info, errInvalidControlFlowX,
|
localError(n.info, errInvalidControlFlowX,
|
||||||
renderTree(n, {renderNoComments}))
|
renderTree(n, {renderNoComments}))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue