summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/glslang/src/Test/switch.frag
blob: f0860fae810fb7e0abfa7e3d060d575121b74870 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#version 300 es
precision highp float;
uniform int c, d;
in highp float x;

void main()
{
    float f;
    int a[2];

    switch(f) {      // ERROR
    }

    switch(a) {      // ERROR
    }

    switch(c)
    {
    }

    switch(c)        // WARNING, not enough stuff after last label
    {
    case 2:
    }

    switch(c)
    {
        f = sin(x);   // ERRROR
    case 2:
        f = cos(x);
        break;
    }

    switch (c) {
    default:
        break;
    case 1:
        f = sin(x);
        break;
    case 2:
        f = cos(x);
        break;
    default:           // ERROR, 2nd default
        f = tan(x);
    }

    switch (c) {
    case 1:
        f = sin(x);
        break;
    case 2:
        switch (d) {
        case 1:
            f = x * x * x;
            break;
        case 2:
            f = x * x;
            break;
        }
        break;
    default:
        f = tan(x);
    case 1:           // ERROR, 2nd 'case 1'
        break;
    case 3.8:         // ERROR, non-int
        break;
    case c:           // ERROR, non-constant
        break;       
    }

    switch (c) {      // a no-error normal switch
    case 1:
        f = sin(x);
        break;
    case 2:
        switch (d) {
        case 1:
            f = x * x * x;
            break;
        case 2:
            f = x * x;
            break;
        }
        break;
    default:
        f = tan(x);
    }

    break;            // ERROR

    switch (c) {
    case 1:
        f = sin(x);
        break;
    case 2:
        switch (d) {
        case 1:
            {
                case 4:        // ERROR
                    break;
            }
            f = x * x * x;
            if (c < d) {
                case 2:         // ERROR
                    f = x * x;
            }
            if (d < c)
                case 3:         // ERROR
            break;
        }
        break;
    case 4:
        f = tan(x);
        if (f < 0.0)
            default:            // ERROR
                break;
    }

    case 5:  // ERROR
    default: // ERROR

    switch (0) {
        default:
        int onlyInSwitch = 0;
    }
    onlyInSwitch;   // ERROR
   
    switch (0) {
        default:
            int x;  // WARNING (was "no statement" ERROR, but spec. changed because unclear what a statement is)
    }

    switch (c) {
    case 1:
    {
        int nestedX;
        break;
    }
    case 2:
        nestedX;    // ERROR
        int nestedZ;
        float a;    // okay, hiding outer 'a'
        break;
    case 3:
        int linearZ;
        break;
        break;
    case 4:
        int linearY = linearZ;
        break;
    case 5:         // okay that branch bypassed an initializer
        const int linearC = 4;
        break;
    case 6:         // okay that branch bypassed an initializer
        linearC;
    }
    nestedZ;        // ERROR, no longer in scope
}