1cb93a386Sopenharmony_ci// Expect 3 errors
2cb93a386Sopenharmony_ci
3cb93a386Sopenharmony_ci// Legal cases that should not produce errors:
4cb93a386Sopenharmony_civoid literal_index()    { int a[2]; a[0] = 0; a[1] = a[0]; }
5cb93a386Sopenharmony_civoid const_var_index()  { int a[2]; const int b = 0; a[b] = 0; }
6cb93a386Sopenharmony_civoid loop_index()       { int a[2]; for (int i = 0; i <  2; ++i) { a[i]             = i; } }
7cb93a386Sopenharmony_civoid loop_expr_binary() { int a[2]; for (int i = 0; i <  2; ++i) { a[1 - i]         = i; } }
8cb93a386Sopenharmony_civoid loop_expr_unary()  { int a[2]; for (int i = 0; i > -2; --i) { a[-i]            = i; } }
9cb93a386Sopenharmony_civoid loop_swizzle()     { int a[2]; for (int i = 0; i <  2; ++i) { a[i.x]           = i; } }
10cb93a386Sopenharmony_civoid loop_ternary()     { int a[2]; for (int i = 0; i <  2; ++i) { a[i > 0 ? i : 0] = i; } }
11cb93a386Sopenharmony_ci
12cb93a386Sopenharmony_civoid loop_type_coerce() { float a[2]; for (float i = 0; i < 2; ++i) { a[int(i)] = i; } }
13cb93a386Sopenharmony_ci
14cb93a386Sopenharmony_civoid loop_nested() {
15cb93a386Sopenharmony_ci    int a[3];
16cb93a386Sopenharmony_ci    for (int i = 0; i < 2; ++i)
17cb93a386Sopenharmony_ci    for (int j = 0; j < 2; ++j) {
18cb93a386Sopenharmony_ci      a[i + j] = j;
19cb93a386Sopenharmony_ci    }
20cb93a386Sopenharmony_ci}
21cb93a386Sopenharmony_ci
22cb93a386Sopenharmony_ciuniform int u;
23cb93a386Sopenharmony_ci
24cb93a386Sopenharmony_ci// Illegal cases that should produce errors:
25cb93a386Sopenharmony_civoid uniform_index()    { int a[2]; a[u] = 0; }
26cb93a386Sopenharmony_civoid param_index(int p) { int a[2]; a[p] = 0; }
27cb93a386Sopenharmony_ci
28cb93a386Sopenharmony_ci// Legal in SkSL when optimization is enabled:
29cb93a386Sopenharmony_civoid func_index()      { int a[2]; a[int(abs(-1))] = 0; }
30