xref: /aosp_15_r20/external/skia/resources/sksl/runtime_errors/LoopStructureErrors.rts (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1// Expect 15 errors
2
3void loop_length_128()    { for (int i = 0; i < 128; i++) {} }   // OK, under kLoopTerminationLimit
4void loop_length_129()    { for (int i = 0; i < 129; i++) {} }   // OK, under kLoopTerminationLimit
5void loop_length_99999()  { for (int i = 0; i < 99999; i++) {} } // OK, under kLoopTerminationLimit
6void loop_length_100000() { for (int i = 0; i < 100000; i++) {} }
7void infinite_loop1()     { for (int i = 0; i < 1;  i += 0) {} }
8void infinite_loop2()     { for (int i = 3; i >= 3; i += 0) {} }
9void infinite_loop3()     { for (float i = 3; i >= 3; i += 1e-20) {} }
10
11void set(out int x)   { x = 1; }
12void inc(inout int x) { x++; }
13
14void index_modified()    { for (int i = 0; i < 2; i++) { i++; } }
15void index_out_param()   { for (int i = 0; i < 1; i++) { set(i); } }
16void index_inout_param() { for (int i = 0; i < 1; i++) { inc(i); } }
17
18void infinite_loop_le()   { for (int i = 0; i <= 3; --i)  {} }
19void infinite_loop_lt()   { for (int i = 0; i <  4; --i)  {} }
20void infinite_loop_ge()   { for (int i = 3; i >= 0; ++i)  {} }
21void infinite_loop_gt()   { for (int i = 3; i > -1; ++i)  {} }
22void infinite_loop_eq1()  { for (int i = 0; i == 0; i-=0) {} }
23void infinite_loop_eq2()  { for (int i = 1; i == 1; i+=0) {} }
24void infinite_loop_ne1()  { for (int i = 0; i != 4; i--)  {} }
25void infinite_loop_ne2()  { for (int i = 0; i != 4; i+=3) {} }
26
27/*%%*
28loop must guarantee termination in fewer iterations
29invalid loop expression
30invalid loop expression
31loop must guarantee termination in fewer iterations
32loop index must not be modified within body of the loop
33loop index must not be modified within body of the loop
34loop index must not be modified within body of the loop
35loop must guarantee termination in fewer iterations
36loop must guarantee termination in fewer iterations
37loop must guarantee termination in fewer iterations
38loop must guarantee termination in fewer iterations
39invalid loop expression
40invalid loop expression
41loop must guarantee termination in fewer iterations
42loop must guarantee termination in fewer iterations
43*%%*/
44