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
@@ -141,67 +141,68 @@ L0:
1 <START>
2 mark({ while (cond()) { try { doSmth() } catch (e: NullPointerException) { doSmth1() } catch (e: Exception) { doSmth2() } finally { if (cond()) return else continue } } })
L2 [loop entry point]:
L5 [condition entry point]:
mark(cond()) PREV:[mark({ while (cond()) { try { doSmth() } catch (e: NullPointerException) { doSmth1() } catch (e: Exception) { doSmth2() } finally { if (cond()) return else continue } } }), jmp(L5 [condition entry point]), jmp(L5 [condition entry point])]
L6 [condition entry point]:
mark(cond()) PREV:[mark({ while (cond()) { try { doSmth() } catch (e: NullPointerException) { doSmth1() } catch (e: Exception) { doSmth2() } finally { if (cond()) return else continue } } }), jmp(L6 [condition entry point]), jmp(L6 [condition entry point])]
call(cond(), cond) -> <v0>
mark(while (cond()) { try { doSmth() } catch (e: NullPointerException) { doSmth1() } catch (e: Exception) { doSmth2() } finally { if (cond()) return else continue } })
jf(L3 [loop exit point]|<v0>) NEXT:[read (Unit), mark({ try { doSmth() } catch (e: NullPointerException) { doSmth1() } catch (e: Exception) { doSmth2() } finally { if (cond()) return else continue } })]
L4 [body entry point]:
3 mark({ try { doSmth() } catch (e: NullPointerException) { doSmth1() } catch (e: Exception) { doSmth2() } finally { if (cond()) return else continue } })
mark(try { doSmth() } catch (e: NullPointerException) { doSmth1() } catch (e: Exception) { doSmth2() } finally { if (cond()) return else continue })
jmp?(L6 [onException]) NEXT:[jmp?(L9 [catch 0]), jmp?(L7 [onExceptionToFinallyBlock])]
jmp?(L7 [onExceptionToFinallyBlock]) NEXT:[mark({ if (cond()) return else continue }), mark({ doSmth() })]
jmp?(L7 [onException]) NEXT:[jmp?(L10 [catch 0]), jmp?(L8 [onExceptionToFinallyBlock])]
jmp?(L8 [onExceptionToFinallyBlock]) NEXT:[mark({ if (cond()) return else continue }), mark({ doSmth() })]
4 mark({ doSmth() })
mark(doSmth())
call(doSmth(), doSmth) -> <v1>
3 jmp(L8 [afterCatches]) NEXT:[jmp(L10 [skipFinallyToErrorBlock])]
L6 [onException]:
jmp?(L9 [catch 0]) NEXT:[v(e: Exception), v(e: NullPointerException)] PREV:[jmp?(L6 [onException])]
3 jmp(L9 [afterCatches]) NEXT:[jmp(L11 [skipFinallyToErrorBlock])]
L7 [onException]:
jmp?(L10 [catch 0]) NEXT:[v(e: Exception), v(e: NullPointerException)] PREV:[jmp?(L7 [onException])]
4 v(e: NullPointerException)
magic[FAKE_INITIALIZER](e: NullPointerException) -> <v2>
w(e|<v2>)
5 mark({ doSmth1() })
mark(doSmth1())
call(doSmth1(), doSmth1) -> <v3>
4 jmp(L8 [afterCatches]) NEXT:[jmp(L10 [skipFinallyToErrorBlock])]
L9 [catch 0]:
v(e: Exception) PREV:[jmp?(L9 [catch 0])]
4 jmp(L9 [afterCatches]) NEXT:[jmp(L11 [skipFinallyToErrorBlock])]
L10 [catch 0]:
v(e: Exception) PREV:[jmp?(L10 [catch 0])]
magic[FAKE_INITIALIZER](e: Exception) -> <v4>
w(e|<v4>)
5 mark({ doSmth2() })
mark(doSmth2())
call(doSmth2(), doSmth2) -> <v5>
4 jmp(L8 [afterCatches])
L8 [afterCatches]:
3 jmp(L10 [skipFinallyToErrorBlock]) NEXT:[mark({ if (cond()) return else continue })] PREV:[jmp(L8 [afterCatches]), jmp(L8 [afterCatches]), jmp(L8 [afterCatches])]
L7 [onExceptionToFinallyBlock]:
L11 [start finally]:
4 mark({ if (cond()) return else continue }) PREV:[jmp?(L7 [onExceptionToFinallyBlock])]
4 jmp(L9 [afterCatches])
L9 [afterCatches]:
3 jmp(L11 [skipFinallyToErrorBlock]) NEXT:[mark({ if (cond()) return else continue })] PREV:[jmp(L9 [afterCatches]), jmp(L9 [afterCatches]), jmp(L9 [afterCatches])]
L8 [onExceptionToFinallyBlock]:
L12 [start finally]:
4 mark({ if (cond()) return else continue }) PREV:[jmp?(L8 [onExceptionToFinallyBlock])]
mark(if (cond()) return else continue)
mark(cond())
call(cond(), cond) -> <v6>
jf(L12 [else branch]|<v6>) NEXT:[jmp(L5 [condition entry point]), ret L1]
jf(L13 [else branch]|<v6>) NEXT:[jmp(L6 [condition entry point]), ret L1]
ret L1 NEXT:[<END>]
- jmp(L13 ['if' expression result]) NEXT:[merge(if (cond()) return else continue|!<v7>, !<v8>) -> <v9>] PREV:[]
L12 [else branch]:
jmp(L5 [condition entry point]) NEXT:[mark(cond())] PREV:[jf(L12 [else branch]|<v6>)]
L13 ['if' expression result]:
- jmp(L14 ['if' expression result]) NEXT:[merge(if (cond()) return else continue|!<v7>, !<v8>) -> <v9>] PREV:[]
L13 [else branch]:
jmp(L6 [condition entry point]) NEXT:[mark(cond())] PREV:[jf(L13 [else branch]|<v6>)]
L14 ['if' expression result]:
- merge(if (cond()) return else continue|!<v7>, !<v8>) -> <v9> PREV:[]
L14 [finish finally]:
L15 [finish finally]:
- 3 jmp(error) NEXT:[<ERROR>] PREV:[]
L10 [skipFinallyToErrorBlock]:
4 mark({ if (cond()) return else continue }) PREV:[jmp(L10 [skipFinallyToErrorBlock])]
L11 [skipFinallyToErrorBlock]:
4 mark({ if (cond()) return else continue }) PREV:[jmp(L11 [skipFinallyToErrorBlock])]
mark(if (cond()) return else continue)
mark(cond())
call(cond(), cond) -> <v6>
jf(copy L12 [else branch]|<v6>) NEXT:[jmp(L5 [condition entry point]), ret L1]
jf(copy L13 [else branch]|<v6>) NEXT:[jmp(L6 [condition entry point]), ret L1]
ret L1 NEXT:[<END>]
- jmp(copy L13 ['if' expression result]) NEXT:[merge(if (cond()) return else continue|!<v7>, !<v8>) -> <v9>] PREV:[]
jmp(L5 [condition entry point]) NEXT:[mark(cond())] PREV:[jf(copy L12 [else branch]|<v6>)]
- jmp(copy L14 ['if' expression result]) NEXT:[merge(if (cond()) return else continue|!<v7>, !<v8>) -> <v9>] PREV:[]
jmp(L6 [condition entry point]) NEXT:[mark(cond())] PREV:[jf(copy L13 [else branch]|<v6>)]
- merge(if (cond()) return else continue|!<v7>, !<v8>) -> <v9> PREV:[]
- 3 merge(try { doSmth() } catch (e: NullPointerException) { doSmth1() } catch (e: Exception) { doSmth2() } finally { if (cond()) return else continue }|<v1>, <v3>, <v5>) -> <v10> PREV:[]
- 2 jmp(L2 [loop entry point]) NEXT:[mark(cond())] PREV:[]
L3 [loop exit point]:
L5 [body exit point]:
read (Unit) PREV:[jf(L3 [loop exit point]|<v0>)]
L1:
1 <END> NEXT:[<SINK>] PREV:[ret L1, ret L1, read (Unit)]
@@ -259,7 +260,7 @@ L3 [onExceptionToFinallyBlock]:
L7 [start finally]:
3 mark({ while (cond()); }) PREV:[jmp?(L3 [onExceptionToFinallyBlock])]
L8 [loop entry point]:
L11 [condition entry point]:
L12 [condition entry point]:
mark(cond()) PREV:[mark({ while (cond()); }), jmp(L8 [loop entry point])]
call(cond(), cond) -> <v5>
mark(while (cond()))
@@ -267,8 +268,9 @@ L11 [condition entry point]:
L10 [body entry point]:
jmp(L8 [loop entry point]) NEXT:[mark(cond())]
L9 [loop exit point]:
L11 [body exit point]:
read (Unit) PREV:[jf(L9 [loop exit point]|<v5>)]
L12 [finish finally]:
L13 [finish finally]:
2 jmp(error) NEXT:[<ERROR>]
L6 [skipFinallyToErrorBlock]:
3 mark({ while (cond()); }) PREV:[jmp(L6 [skipFinallyToErrorBlock])]