skia2/tests/sksl/runtime_errors/LoopStructureErrors.skvm
Ethan Nicholas f125d4e7a0 Improved SkSL Block and Do position tracking
Blocks did not previously track their position, creating problems
reporting some errors (which will be improved in followup CLs). Fixing
block positions changed the reporting of do loop errors, requiring do
loop position tracking to be updated as part of this change.

Change-Id: I3bd048a62d912914edf679f42607de1b5eafc2b9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/528045
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2022-04-07 21:03:19 +00:00

49 lines
2.7 KiB
Plaintext

### Compilation failed:
error: 6: loop must guarantee termination in fewer iterations
void loop_length_100000() { for (int i = 0; i < 100000; i++) {} }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: 7: invalid loop expression
void infinite_loop1() { for (int i = 0; i < 1; i += 0) {} }
^^^^^^
error: 8: invalid loop expression
void infinite_loop2() { for (int i = 3; i >= 3; i += 0) {} }
^^^^^^
error: 9: loop must guarantee termination in fewer iterations
void infinite_loop3() { for (float i = 3; i >= 3; i += 1e-20) {} }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: 14: loop index must not be modified within body of the loop
void index_modified() { for (int i = 0; i < 2; i++) { i++; } }
^^^^^^^^
error: 15: loop index must not be modified within body of the loop
void index_out_param() { for (int i = 0; i < 1; i++) { set(i); } }
^^^^^^^^^^^
error: 16: loop index must not be modified within body of the loop
void index_inout_param() { for (int i = 0; i < 1; i++) { inc(i); } }
^^^^^^^^^^^
error: 18: loop must guarantee termination in fewer iterations
void infinite_loop_le() { for (int i = 0; i <= 3; --i) {} }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: 19: loop must guarantee termination in fewer iterations
void infinite_loop_lt() { for (int i = 0; i < 4; --i) {} }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: 20: loop must guarantee termination in fewer iterations
void infinite_loop_ge() { for (int i = 3; i >= 0; ++i) {} }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: 21: loop must guarantee termination in fewer iterations
void infinite_loop_gt() { for (int i = 3; i > -1; ++i) {} }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: 22: invalid loop expression
void infinite_loop_eq1() { for (int i = 0; i == 0; i-=0) {} }
^^^^
error: 23: invalid loop expression
void infinite_loop_eq2() { for (int i = 1; i == 1; i+=0) {} }
^^^^
error: 24: loop must guarantee termination in fewer iterations
void infinite_loop_ne1() { for (int i = 0; i != 4; i--) {} }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: 25: loop must guarantee termination in fewer iterations
void infinite_loop_ne2() { for (int i = 0; i != 4; i+=3) {} }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15 errors