Files
kotlin-fork/compiler/testData/cfg/controlStructures/continueInDoWhile.instructions
T
Svetlana Isakova 61dc110cc7 Report 'break or continue outside a loop'
for break/continue outside a loop body (e.g. in loop condition)

 #KT-5724 Fixed
2014-09-07 01:03:57 +04:00

42 lines
1.7 KiB
Plaintext

== test ==
fun test(b: Boolean) {
do {
if (b) break;
continue;
} while (true);
}
---------------------
L0:
1 <START>
v(b: Boolean)
magic[FAKE_INITIALIZER](b: Boolean) -> <v0>
w(b|<v0>)
2 mark({ do { if (b) break; continue; } while (true); })
3 mark(do { if (b) break; continue; } while (true))
L2 [loop entry point]:
L4 [body entry point]:
mark({ if (b) break; continue; }) PREV:[mark(do { if (b) break; continue; } while (true)), jt(L2 [loop entry point]|<v5>)]
mark(if (b) break)
r(b) -> <v1>
jf(L7 [else branch]|<v1>) NEXT:[read (Unit), jmp(L3 [loop exit point])]
jmp(L3 [loop exit point]) NEXT:[read (Unit)]
- jmp(L8 ['if' expression result]) NEXT:[merge(if (b) break|!<v2>) -> <v3>] PREV:[]
L7 [else branch]:
read (Unit) PREV:[jf(L7 [else branch]|<v1>)]
L8 ['if' expression result]:
merge(if (b) break|!<v2>) -> <v3>
jmp(L6 [condition entry point])
L5 [body exit point]:
L6 [condition entry point]:
r(true) -> <v5>
jt(L2 [loop entry point]|<v5>) NEXT:[read (Unit), mark({ if (b) break; continue; })]
L3 [loop exit point]:
read (Unit) PREV:[jmp(L3 [loop exit point]), jt(L2 [loop entry point]|<v5>)]
L1:
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================