skia2/resources/sksl/runtime_errors/LoopStructureErrors.rts
John Stiles 106e0cd412 Increase GetLoopUnrollInfo loop-count limit to 100,000.
To do this with a clean conscience, I needed to convert the unroll-
counting logic from a linear time algorithm to constant-time. Getting
all the edge cases correct requires a lot of care, and there are now
plenty of unit tests.

Change-Id: I620909d069ac425b7310e345bf80ec844fe035f8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/445643
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-09-07 19:28:08 +00:00

26 lines
1.3 KiB
Plaintext

// Expect 15 errors
void loop_length_128() { for (int i = 0; i < 128; i++) {} } // OK, under kLoopTerminationLimit
void loop_length_129() { for (int i = 0; i < 129; i++) {} } // OK, under kLoopTerminationLimit
void loop_length_99999() { for (int i = 0; i < 99999; i++) {} } // OK, under kLoopTerminationLimit
void loop_length_100000() { for (int i = 0; i < 100000; i++) {} }
void infinite_loop1() { for (int i = 0; i < 1; i += 0) {} }
void infinite_loop2() { for (int i = 3; i >= 3; i += 0) {} }
void infinite_loop3() { for (float i = 3; i >= 3; i += 1e-20) {} }
void set(out int x) { x = 1; }
void inc(inout int x) { x++; }
void index_modified() { for (int i = 0; i < 2; i++) { i++; } }
void index_out_param() { for (int i = 0; i < 1; i++) { set(i); } }
void index_inout_param() { for (int i = 0; i < 1; i++) { inc(i); } }
void infinite_loop_le() { for (int i = 0; i <= 3; --i) {} }
void infinite_loop_lt() { for (int i = 0; i < 4; --i) {} }
void infinite_loop_ge() { for (int i = 3; i >= 0; ++i) {} }
void infinite_loop_gt() { for (int i = 3; i > -1; ++i) {} }
void infinite_loop_eq1() { for (int i = 0; i == 0; i-=0) {} }
void infinite_loop_eq2() { for (int i = 1; i == 1; i+=0) {} }
void infinite_loop_ne1() { for (int i = 0; i != 4; i--) {} }
void infinite_loop_ne2() { for (int i = 0; i != 4; i+=3) {} }