Report 'break or continue outside a loop'

for break/continue outside a loop body (e.g. in loop condition)

 #KT-5724 Fixed
This commit is contained in:
Svetlana Isakova
2014-09-01 19:01:47 +04:00
parent 0b4f313b6d
commit 61dc110cc7
22 changed files with 355 additions and 275 deletions
@@ -13,24 +13,25 @@ L0:
w(b|<v0>)
2 mark({ while (true) { if (b) break; continue; } })
L2 [loop entry point]:
L5 [condition entry point]:
r(true) -> <v1> PREV:[mark({ while (true) { if (b) break; continue; } }), jmp(L5 [condition entry point])]
L6 [condition entry point]:
r(true) -> <v1> PREV:[mark({ while (true) { if (b) break; continue; } }), jmp(L6 [condition entry point])]
mark(while (true) { if (b) break; continue; })
magic[VALUE_CONSUMER](true|<v1>) -> <v2>
L4 [body entry point]:
3 mark({ if (b) break; continue; })
mark(if (b) break)
r(b) -> <v3>
jf(L6 [else branch]|<v3>) NEXT:[read (Unit), jmp(L3 [loop exit point])]
jf(L7 [else branch]|<v3>) NEXT:[read (Unit), jmp(L3 [loop exit point])]
jmp(L3 [loop exit point]) NEXT:[read (Unit)]
- jmp(L7 ['if' expression result]) NEXT:[merge(if (b) break|!<v4>) -> <v5>] PREV:[]
L6 [else branch]:
read (Unit) PREV:[jf(L6 [else branch]|<v3>)]
L7 ['if' expression result]:
- jmp(L8 ['if' expression result]) NEXT:[merge(if (b) break|!<v4>) -> <v5>] PREV:[]
L7 [else branch]:
read (Unit) PREV:[jf(L7 [else branch]|<v3>)]
L8 ['if' expression result]:
merge(if (b) break|!<v4>) -> <v5>
jmp(L5 [condition entry point]) NEXT:[r(true) -> <v1>]
jmp(L6 [condition entry point]) NEXT:[r(true) -> <v1>]
- 2 jmp(L2 [loop entry point]) NEXT:[r(true) -> <v1>] PREV:[]
L3 [loop exit point]:
L5 [body exit point]:
read (Unit) PREV:[jmp(L3 [loop exit point])]
L1:
1 <END> NEXT:[<SINK>]
@@ -38,4 +39,4 @@ error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
=====================