xref: /aosp_15_r20/external/skia/resources/sksl/shared/ForLoopMultipleInitES3.sksl (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1uniform half4 colorGreen, colorRed;
2
3half4 main(float2 coords) {
4    // Two variables, both used.
5    half sumA = 0, sumB = 0;
6    for (half a = 0, b = 10; a < 10 && b > 0; ++a, --b) {
7        sumA += a;
8        sumB += b;
9    }
10    if (sumA != 45 || sumB != 55) {
11        return colorRed;
12    }
13
14    // Two variables, one dead
15    int sumC = 0;
16    for (int c = 0, d = 0; c < 10; ++c) {
17        sumC += c;
18    }
19    if (sumC != 45) {
20        return colorRed;
21    }
22
23    // Three variables, all used, some array-typed
24    float sumE = 0.0;
25    for (float d[2] = float[2](0, 10), e[4] = float[4](1,2,3,4), f = 0; d[0] < d[1]; ++d[0]) {
26        sumE += half(e[0]);
27    }
28    if (sumE != 10) {
29        return colorRed;
30    }
31
32    // Four variables, all dead
33    for (half4 x, y, z, w;; ) break;
34
35    // Just referencing a variable instead of declaring it--legal, if not meaningful.
36    for (sumA;; ) return colorGreen;
37}
38