diff options
author | Araq <rumpf_a@web.de> | 2014-09-03 19:54:20 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2014-09-03 19:54:20 +0200 |
commit | e093f45756e847f097d06511d91d76f549ee6644 (patch) | |
tree | 244c829e0719b42a67e1a39e8aa1b9c19e161811 /compiler/semstmts.nim | |
parent | 201a08e9a54cf129aca33d43d57cadd29e564149 (diff) | |
download | Nim-e093f45756e847f097d06511d91d76f549ee6644.tar.gz |
fixes #1511
Diffstat (limited to 'compiler/semstmts.nim')
-rw-r--r-- | compiler/semstmts.nim | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 89acb2e98..28d062392 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -22,21 +22,24 @@ proc semDiscard(c: PContext, n: PNode): PNode = proc semBreakOrContinue(c: PContext, n: PNode): PNode = result = n checkSonsLen(n, 1) - if n.sons[0].kind != nkEmpty: - var s: PSym - case n.sons[0].kind - of nkIdent: s = lookUp(c, n.sons[0]) - of nkSym: s = n.sons[0].sym - else: illFormedAst(n) - if s.kind == skLabel and s.owner.id == c.p.owner.id: - var x = newSymNode(s) - x.info = n.info - incl(s.flags, sfUsed) - n.sons[0] = x - suggestSym(x.info, s) + if n.sons[0].kind != nkEmpty: + if n.kind != nkContinueStmt: + var s: PSym + case n.sons[0].kind + of nkIdent: s = lookUp(c, n.sons[0]) + of nkSym: s = n.sons[0].sym + else: illFormedAst(n) + if s.kind == skLabel and s.owner.id == c.p.owner.id: + var x = newSymNode(s) + x.info = n.info + incl(s.flags, sfUsed) + n.sons[0] = x + suggestSym(x.info, s) + else: + localError(n.info, errInvalidControlFlowX, s.name.s) else: - localError(n.info, errInvalidControlFlowX, s.name.s) - elif (c.p.nestedLoopCounter <= 0) and (c.p.nestedBlockCounter <= 0): + localError(n.info, errGenerated, "'continue' cannot have a label") + elif (c.p.nestedLoopCounter <= 0) and (c.p.nestedBlockCounter <= 0): localError(n.info, errInvalidControlFlowX, renderTree(n, {renderNoComments})) |