xref: /aosp_15_r20/external/deqp/data/gles2/shaders/scoping.test (revision 35238bce31c2a825756842865a792f8cf7f89930)
1*35238bceSAndroid Build Coastguard Workergroup valid "Valid scoping and name redeclaration cases"
2*35238bceSAndroid Build Coastguard Worker
3*35238bceSAndroid Build Coastguard Worker    case local_variable_hides_global_variable
4*35238bceSAndroid Build Coastguard Worker        version 100 es
5*35238bceSAndroid Build Coastguard Worker        values
6*35238bceSAndroid Build Coastguard Worker        {
7*35238bceSAndroid Build Coastguard Worker            input int in0 = [ 1 | 2 | 3 ];
8*35238bceSAndroid Build Coastguard Worker            output int out0 = [ 1 | 2 | 3 ];
9*35238bceSAndroid Build Coastguard Worker        }
10*35238bceSAndroid Build Coastguard Worker
11*35238bceSAndroid Build Coastguard Worker        both ""
12*35238bceSAndroid Build Coastguard Worker            #version 100
13*35238bceSAndroid Build Coastguard Worker            precision mediump float;
14*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
15*35238bceSAndroid Build Coastguard Worker
16*35238bceSAndroid Build Coastguard Worker            int a = -1;
17*35238bceSAndroid Build Coastguard Worker
18*35238bceSAndroid Build Coastguard Worker            void main()
19*35238bceSAndroid Build Coastguard Worker            {
20*35238bceSAndroid Build Coastguard Worker                ${SETUP}
21*35238bceSAndroid Build Coastguard Worker                int a = in0;
22*35238bceSAndroid Build Coastguard Worker
23*35238bceSAndroid Build Coastguard Worker                out0 = a;
24*35238bceSAndroid Build Coastguard Worker                ${OUTPUT}
25*35238bceSAndroid Build Coastguard Worker            }
26*35238bceSAndroid Build Coastguard Worker        ""
27*35238bceSAndroid Build Coastguard Worker    end
28*35238bceSAndroid Build Coastguard Worker
29*35238bceSAndroid Build Coastguard Worker    case block_variable_hides_local_variable
30*35238bceSAndroid Build Coastguard Worker        version 100 es
31*35238bceSAndroid Build Coastguard Worker        values
32*35238bceSAndroid Build Coastguard Worker        {
33*35238bceSAndroid Build Coastguard Worker            input int in0 = [ 1 | 2 | 3 ];
34*35238bceSAndroid Build Coastguard Worker            output int out0 = [ 1 | 2 | 3 ];
35*35238bceSAndroid Build Coastguard Worker        }
36*35238bceSAndroid Build Coastguard Worker
37*35238bceSAndroid Build Coastguard Worker        both ""
38*35238bceSAndroid Build Coastguard Worker            #version 100
39*35238bceSAndroid Build Coastguard Worker            precision mediump float;
40*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
41*35238bceSAndroid Build Coastguard Worker            void main()
42*35238bceSAndroid Build Coastguard Worker            {
43*35238bceSAndroid Build Coastguard Worker                ${SETUP}
44*35238bceSAndroid Build Coastguard Worker                int a = in0;
45*35238bceSAndroid Build Coastguard Worker                {
46*35238bceSAndroid Build Coastguard Worker                    int a = -1;
47*35238bceSAndroid Build Coastguard Worker                }
48*35238bceSAndroid Build Coastguard Worker                out0 = a;
49*35238bceSAndroid Build Coastguard Worker                ${OUTPUT}
50*35238bceSAndroid Build Coastguard Worker            }
51*35238bceSAndroid Build Coastguard Worker        ""
52*35238bceSAndroid Build Coastguard Worker    end
53*35238bceSAndroid Build Coastguard Worker
54*35238bceSAndroid Build Coastguard Worker    case block_variable_hides_global_variable
55*35238bceSAndroid Build Coastguard Worker        version 100 es
56*35238bceSAndroid Build Coastguard Worker        values
57*35238bceSAndroid Build Coastguard Worker        {
58*35238bceSAndroid Build Coastguard Worker            input int in0 = [ 1 | 2 | 3 ];
59*35238bceSAndroid Build Coastguard Worker            output int out0 = [ 1 | 2 | 3 ];
60*35238bceSAndroid Build Coastguard Worker        }
61*35238bceSAndroid Build Coastguard Worker
62*35238bceSAndroid Build Coastguard Worker        both ""
63*35238bceSAndroid Build Coastguard Worker            #version 100
64*35238bceSAndroid Build Coastguard Worker            precision mediump float;
65*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
66*35238bceSAndroid Build Coastguard Worker
67*35238bceSAndroid Build Coastguard Worker            int a = -1;
68*35238bceSAndroid Build Coastguard Worker
69*35238bceSAndroid Build Coastguard Worker            void main()
70*35238bceSAndroid Build Coastguard Worker            {
71*35238bceSAndroid Build Coastguard Worker                ${SETUP}
72*35238bceSAndroid Build Coastguard Worker                {
73*35238bceSAndroid Build Coastguard Worker                    int a = in0;
74*35238bceSAndroid Build Coastguard Worker
75*35238bceSAndroid Build Coastguard Worker                    out0 = a;
76*35238bceSAndroid Build Coastguard Worker                }
77*35238bceSAndroid Build Coastguard Worker                ${OUTPUT}
78*35238bceSAndroid Build Coastguard Worker            }
79*35238bceSAndroid Build Coastguard Worker        ""
80*35238bceSAndroid Build Coastguard Worker    end
81*35238bceSAndroid Build Coastguard Worker
82*35238bceSAndroid Build Coastguard Worker    case for_init_statement_variable_hides_local_variable
83*35238bceSAndroid Build Coastguard Worker        version 100 es
84*35238bceSAndroid Build Coastguard Worker        values
85*35238bceSAndroid Build Coastguard Worker        {
86*35238bceSAndroid Build Coastguard Worker            input int in0 = [ 1 | 2 | 3 ];
87*35238bceSAndroid Build Coastguard Worker            output int out0 = [ 1 | 2 | 3 ];
88*35238bceSAndroid Build Coastguard Worker        }
89*35238bceSAndroid Build Coastguard Worker
90*35238bceSAndroid Build Coastguard Worker        both ""
91*35238bceSAndroid Build Coastguard Worker            #version 100
92*35238bceSAndroid Build Coastguard Worker            precision mediump float;
93*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
94*35238bceSAndroid Build Coastguard Worker            void main()
95*35238bceSAndroid Build Coastguard Worker            {
96*35238bceSAndroid Build Coastguard Worker                ${SETUP}
97*35238bceSAndroid Build Coastguard Worker                int a = in0;
98*35238bceSAndroid Build Coastguard Worker                for (int a = 0; a < 10; a++)
99*35238bceSAndroid Build Coastguard Worker                {
100*35238bceSAndroid Build Coastguard Worker                }
101*35238bceSAndroid Build Coastguard Worker                out0 = a;
102*35238bceSAndroid Build Coastguard Worker                ${OUTPUT}
103*35238bceSAndroid Build Coastguard Worker            }
104*35238bceSAndroid Build Coastguard Worker        ""
105*35238bceSAndroid Build Coastguard Worker    end
106*35238bceSAndroid Build Coastguard Worker
107*35238bceSAndroid Build Coastguard Worker    case while_condition_variable_hides_local_variable
108*35238bceSAndroid Build Coastguard Worker        version 100 es
109*35238bceSAndroid Build Coastguard Worker        require full_glsl_es_100_support
110*35238bceSAndroid Build Coastguard Worker        values
111*35238bceSAndroid Build Coastguard Worker        {
112*35238bceSAndroid Build Coastguard Worker            input int in0 = [ 1 | 2 | 3 ];
113*35238bceSAndroid Build Coastguard Worker            output int out0 = [ 1 | 2 | 3 ];
114*35238bceSAndroid Build Coastguard Worker        }
115*35238bceSAndroid Build Coastguard Worker
116*35238bceSAndroid Build Coastguard Worker        both ""
117*35238bceSAndroid Build Coastguard Worker            #version 100
118*35238bceSAndroid Build Coastguard Worker            precision mediump float;
119*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
120*35238bceSAndroid Build Coastguard Worker            void main()
121*35238bceSAndroid Build Coastguard Worker            {
122*35238bceSAndroid Build Coastguard Worker                ${SETUP}
123*35238bceSAndroid Build Coastguard Worker                int a = in0;
124*35238bceSAndroid Build Coastguard Worker                int i = 0;
125*35238bceSAndroid Build Coastguard Worker                while (bool a = (i < 1))
126*35238bceSAndroid Build Coastguard Worker                {
127*35238bceSAndroid Build Coastguard Worker                    i++;
128*35238bceSAndroid Build Coastguard Worker                }
129*35238bceSAndroid Build Coastguard Worker                out0 = a;
130*35238bceSAndroid Build Coastguard Worker                ${OUTPUT}
131*35238bceSAndroid Build Coastguard Worker            }
132*35238bceSAndroid Build Coastguard Worker        ""
133*35238bceSAndroid Build Coastguard Worker    end
134*35238bceSAndroid Build Coastguard Worker
135*35238bceSAndroid Build Coastguard Worker    case for_init_statement_variable_hides_global_variable
136*35238bceSAndroid Build Coastguard Worker        version 100 es
137*35238bceSAndroid Build Coastguard Worker        values
138*35238bceSAndroid Build Coastguard Worker        {
139*35238bceSAndroid Build Coastguard Worker            input int in0 = [ 1 | 2 | 3 ];
140*35238bceSAndroid Build Coastguard Worker            output int out0 = [ 1 | 2 | 3 ];
141*35238bceSAndroid Build Coastguard Worker        }
142*35238bceSAndroid Build Coastguard Worker
143*35238bceSAndroid Build Coastguard Worker        both ""
144*35238bceSAndroid Build Coastguard Worker            #version 100
145*35238bceSAndroid Build Coastguard Worker            precision mediump float;
146*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
147*35238bceSAndroid Build Coastguard Worker
148*35238bceSAndroid Build Coastguard Worker            int a = 5;
149*35238bceSAndroid Build Coastguard Worker
150*35238bceSAndroid Build Coastguard Worker            void main()
151*35238bceSAndroid Build Coastguard Worker            {
152*35238bceSAndroid Build Coastguard Worker                ${SETUP}
153*35238bceSAndroid Build Coastguard Worker                for (int a = 0; a < 10; a++)
154*35238bceSAndroid Build Coastguard Worker                {
155*35238bceSAndroid Build Coastguard Worker                }
156*35238bceSAndroid Build Coastguard Worker                out0 = in0 + a - 5;
157*35238bceSAndroid Build Coastguard Worker                ${OUTPUT}
158*35238bceSAndroid Build Coastguard Worker            }
159*35238bceSAndroid Build Coastguard Worker        ""
160*35238bceSAndroid Build Coastguard Worker    end
161*35238bceSAndroid Build Coastguard Worker
162*35238bceSAndroid Build Coastguard Worker    case while_condition_variable_hides_global_variable
163*35238bceSAndroid Build Coastguard Worker        version 100 es
164*35238bceSAndroid Build Coastguard Worker        require full_glsl_es_100_support
165*35238bceSAndroid Build Coastguard Worker        values
166*35238bceSAndroid Build Coastguard Worker        {
167*35238bceSAndroid Build Coastguard Worker            input int in0 = [ 1 | 2 | 3 ];
168*35238bceSAndroid Build Coastguard Worker            output int out0 = [ 1 | 2 | 3 ];
169*35238bceSAndroid Build Coastguard Worker        }
170*35238bceSAndroid Build Coastguard Worker
171*35238bceSAndroid Build Coastguard Worker        both ""
172*35238bceSAndroid Build Coastguard Worker            #version 100
173*35238bceSAndroid Build Coastguard Worker            precision mediump float;
174*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
175*35238bceSAndroid Build Coastguard Worker
176*35238bceSAndroid Build Coastguard Worker            int a = 5;
177*35238bceSAndroid Build Coastguard Worker
178*35238bceSAndroid Build Coastguard Worker            void main()
179*35238bceSAndroid Build Coastguard Worker            {
180*35238bceSAndroid Build Coastguard Worker                ${SETUP}
181*35238bceSAndroid Build Coastguard Worker                int i = 0;
182*35238bceSAndroid Build Coastguard Worker                while (bool a = (i < 1))
183*35238bceSAndroid Build Coastguard Worker                {
184*35238bceSAndroid Build Coastguard Worker                    i++;
185*35238bceSAndroid Build Coastguard Worker                }
186*35238bceSAndroid Build Coastguard Worker                out0 = in0 + a - 5;
187*35238bceSAndroid Build Coastguard Worker                ${OUTPUT}
188*35238bceSAndroid Build Coastguard Worker            }
189*35238bceSAndroid Build Coastguard Worker        ""
190*35238bceSAndroid Build Coastguard Worker    end
191*35238bceSAndroid Build Coastguard Worker
192*35238bceSAndroid Build Coastguard Worker    case variable_in_if_hides_global_variable
193*35238bceSAndroid Build Coastguard Worker        version 100 es
194*35238bceSAndroid Build Coastguard Worker        values
195*35238bceSAndroid Build Coastguard Worker        {
196*35238bceSAndroid Build Coastguard Worker            input int in0 = [ 1 | 2 | 3 ];
197*35238bceSAndroid Build Coastguard Worker            output int out0 = [ 1 | 2 | 3 ];
198*35238bceSAndroid Build Coastguard Worker        }
199*35238bceSAndroid Build Coastguard Worker
200*35238bceSAndroid Build Coastguard Worker        both ""
201*35238bceSAndroid Build Coastguard Worker            #version 100
202*35238bceSAndroid Build Coastguard Worker            precision mediump float;
203*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
204*35238bceSAndroid Build Coastguard Worker
205*35238bceSAndroid Build Coastguard Worker            int a = 1;
206*35238bceSAndroid Build Coastguard Worker
207*35238bceSAndroid Build Coastguard Worker            void main()
208*35238bceSAndroid Build Coastguard Worker            {
209*35238bceSAndroid Build Coastguard Worker                ${SETUP}
210*35238bceSAndroid Build Coastguard Worker                if (true)
211*35238bceSAndroid Build Coastguard Worker                    int a = 42;
212*35238bceSAndroid Build Coastguard Worker                out0 = a*in0;
213*35238bceSAndroid Build Coastguard Worker                ${OUTPUT}
214*35238bceSAndroid Build Coastguard Worker            }
215*35238bceSAndroid Build Coastguard Worker        ""
216*35238bceSAndroid Build Coastguard Worker    end
217*35238bceSAndroid Build Coastguard Worker
218*35238bceSAndroid Build Coastguard Worker    case variable_from_outer_scope_visible_in_initializer
219*35238bceSAndroid Build Coastguard Worker        version 100 es
220*35238bceSAndroid Build Coastguard Worker        values
221*35238bceSAndroid Build Coastguard Worker        {
222*35238bceSAndroid Build Coastguard Worker            input int in0 = [ 1 | 2 | 3 ];
223*35238bceSAndroid Build Coastguard Worker            output int out0 = [ 1 | 2 | 3 ];
224*35238bceSAndroid Build Coastguard Worker        }
225*35238bceSAndroid Build Coastguard Worker
226*35238bceSAndroid Build Coastguard Worker        both ""
227*35238bceSAndroid Build Coastguard Worker            #version 100
228*35238bceSAndroid Build Coastguard Worker            precision mediump float;
229*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
230*35238bceSAndroid Build Coastguard Worker            void main()
231*35238bceSAndroid Build Coastguard Worker            {
232*35238bceSAndroid Build Coastguard Worker                ${SETUP}
233*35238bceSAndroid Build Coastguard Worker                int a = in0;
234*35238bceSAndroid Build Coastguard Worker                {
235*35238bceSAndroid Build Coastguard Worker                    int a = a+5, b = a-5;
236*35238bceSAndroid Build Coastguard Worker                    out0 = b;
237*35238bceSAndroid Build Coastguard Worker                    a = 42;
238*35238bceSAndroid Build Coastguard Worker                }
239*35238bceSAndroid Build Coastguard Worker                out0 = out0 + a - in0;
240*35238bceSAndroid Build Coastguard Worker                ${OUTPUT}
241*35238bceSAndroid Build Coastguard Worker            }
242*35238bceSAndroid Build Coastguard Worker        ""
243*35238bceSAndroid Build Coastguard Worker    end
244*35238bceSAndroid Build Coastguard Worker
245*35238bceSAndroid Build Coastguard Worker    case local_int_variable_hides_struct_type
246*35238bceSAndroid Build Coastguard Worker        version 100 es
247*35238bceSAndroid Build Coastguard Worker        values
248*35238bceSAndroid Build Coastguard Worker        {
249*35238bceSAndroid Build Coastguard Worker            input int in0 = [ 1 | 2 | 3 ];
250*35238bceSAndroid Build Coastguard Worker            output int out0 = [ 1 | 2 | 3 ];
251*35238bceSAndroid Build Coastguard Worker        }
252*35238bceSAndroid Build Coastguard Worker
253*35238bceSAndroid Build Coastguard Worker        both ""
254*35238bceSAndroid Build Coastguard Worker            #version 100
255*35238bceSAndroid Build Coastguard Worker            precision mediump float;
256*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
257*35238bceSAndroid Build Coastguard Worker
258*35238bceSAndroid Build Coastguard Worker            struct S { int val; };
259*35238bceSAndroid Build Coastguard Worker
260*35238bceSAndroid Build Coastguard Worker            void main()
261*35238bceSAndroid Build Coastguard Worker            {
262*35238bceSAndroid Build Coastguard Worker                ${SETUP}
263*35238bceSAndroid Build Coastguard Worker                int S = S(in0).val;
264*35238bceSAndroid Build Coastguard Worker                out0 = S;
265*35238bceSAndroid Build Coastguard Worker                ${OUTPUT}
266*35238bceSAndroid Build Coastguard Worker            }
267*35238bceSAndroid Build Coastguard Worker        ""
268*35238bceSAndroid Build Coastguard Worker    end
269*35238bceSAndroid Build Coastguard Worker
270*35238bceSAndroid Build Coastguard Worker    case local_struct_variable_hides_struct_type
271*35238bceSAndroid Build Coastguard Worker        version 100 es
272*35238bceSAndroid Build Coastguard Worker        values
273*35238bceSAndroid Build Coastguard Worker        {
274*35238bceSAndroid Build Coastguard Worker            input int in0 = [ 1 | 2 | 3 ];
275*35238bceSAndroid Build Coastguard Worker            output int out0 = [ 1 | 2 | 3 ];
276*35238bceSAndroid Build Coastguard Worker        }
277*35238bceSAndroid Build Coastguard Worker
278*35238bceSAndroid Build Coastguard Worker        both ""
279*35238bceSAndroid Build Coastguard Worker            #version 100
280*35238bceSAndroid Build Coastguard Worker            precision mediump float;
281*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
282*35238bceSAndroid Build Coastguard Worker
283*35238bceSAndroid Build Coastguard Worker            struct S { int val; };
284*35238bceSAndroid Build Coastguard Worker
285*35238bceSAndroid Build Coastguard Worker            void main()
286*35238bceSAndroid Build Coastguard Worker            {
287*35238bceSAndroid Build Coastguard Worker                ${SETUP}
288*35238bceSAndroid Build Coastguard Worker                S S = S(in0);
289*35238bceSAndroid Build Coastguard Worker                out0 = S.val;
290*35238bceSAndroid Build Coastguard Worker                ${OUTPUT}
291*35238bceSAndroid Build Coastguard Worker            }
292*35238bceSAndroid Build Coastguard Worker        ""
293*35238bceSAndroid Build Coastguard Worker    end
294*35238bceSAndroid Build Coastguard Worker
295*35238bceSAndroid Build Coastguard Worker    case local_variable_hides_function
296*35238bceSAndroid Build Coastguard Worker        version 100 es
297*35238bceSAndroid Build Coastguard Worker        values
298*35238bceSAndroid Build Coastguard Worker        {
299*35238bceSAndroid Build Coastguard Worker            input int in0 = [ 1 | 2 | 3 ];
300*35238bceSAndroid Build Coastguard Worker            output int out0 = [ 1 | 2 | 3 ];
301*35238bceSAndroid Build Coastguard Worker        }
302*35238bceSAndroid Build Coastguard Worker
303*35238bceSAndroid Build Coastguard Worker        both ""
304*35238bceSAndroid Build Coastguard Worker            #version 100
305*35238bceSAndroid Build Coastguard Worker            precision mediump float;
306*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
307*35238bceSAndroid Build Coastguard Worker
308*35238bceSAndroid Build Coastguard Worker            int foo (int x) { return x; }
309*35238bceSAndroid Build Coastguard Worker
310*35238bceSAndroid Build Coastguard Worker            void main()
311*35238bceSAndroid Build Coastguard Worker            {
312*35238bceSAndroid Build Coastguard Worker                ${SETUP}
313*35238bceSAndroid Build Coastguard Worker                int foo = in0;
314*35238bceSAndroid Build Coastguard Worker                out0 = foo;
315*35238bceSAndroid Build Coastguard Worker                ${OUTPUT}
316*35238bceSAndroid Build Coastguard Worker            }
317*35238bceSAndroid Build Coastguard Worker        ""
318*35238bceSAndroid Build Coastguard Worker    end
319*35238bceSAndroid Build Coastguard Worker
320*35238bceSAndroid Build Coastguard Worker    case function_parameter_hides_global_variable
321*35238bceSAndroid Build Coastguard Worker        version 100 es
322*35238bceSAndroid Build Coastguard Worker        values
323*35238bceSAndroid Build Coastguard Worker        {
324*35238bceSAndroid Build Coastguard Worker            input int in0 = [ 1 | 2 | 3 ];
325*35238bceSAndroid Build Coastguard Worker            output int out0 = [ 1 | 2 | 3 ];
326*35238bceSAndroid Build Coastguard Worker        }
327*35238bceSAndroid Build Coastguard Worker
328*35238bceSAndroid Build Coastguard Worker        both ""
329*35238bceSAndroid Build Coastguard Worker            #version 100
330*35238bceSAndroid Build Coastguard Worker            precision mediump float;
331*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
332*35238bceSAndroid Build Coastguard Worker
333*35238bceSAndroid Build Coastguard Worker            int a = -1;
334*35238bceSAndroid Build Coastguard Worker
335*35238bceSAndroid Build Coastguard Worker            int func (int a) { return a; }
336*35238bceSAndroid Build Coastguard Worker
337*35238bceSAndroid Build Coastguard Worker            void main()
338*35238bceSAndroid Build Coastguard Worker            {
339*35238bceSAndroid Build Coastguard Worker                ${SETUP}
340*35238bceSAndroid Build Coastguard Worker                out0 = func(in0);
341*35238bceSAndroid Build Coastguard Worker                ${OUTPUT}
342*35238bceSAndroid Build Coastguard Worker            }
343*35238bceSAndroid Build Coastguard Worker        ""
344*35238bceSAndroid Build Coastguard Worker    end
345*35238bceSAndroid Build Coastguard Worker
346*35238bceSAndroid Build Coastguard Worker    case function_parameter_hides_struct_type
347*35238bceSAndroid Build Coastguard Worker        version 100 es
348*35238bceSAndroid Build Coastguard Worker        values
349*35238bceSAndroid Build Coastguard Worker        {
350*35238bceSAndroid Build Coastguard Worker            input int in0 = [ 1 | 2 | 3 ];
351*35238bceSAndroid Build Coastguard Worker            output int out0 = [ 1 | 2 | 3 ];
352*35238bceSAndroid Build Coastguard Worker        }
353*35238bceSAndroid Build Coastguard Worker
354*35238bceSAndroid Build Coastguard Worker        both ""
355*35238bceSAndroid Build Coastguard Worker            #version 100
356*35238bceSAndroid Build Coastguard Worker            precision mediump float;
357*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
358*35238bceSAndroid Build Coastguard Worker
359*35238bceSAndroid Build Coastguard Worker            struct S { int x; };
360*35238bceSAndroid Build Coastguard Worker
361*35238bceSAndroid Build Coastguard Worker            int func (int S) { return S; }
362*35238bceSAndroid Build Coastguard Worker
363*35238bceSAndroid Build Coastguard Worker            void main()
364*35238bceSAndroid Build Coastguard Worker            {
365*35238bceSAndroid Build Coastguard Worker                ${SETUP}
366*35238bceSAndroid Build Coastguard Worker                out0 = func(in0);
367*35238bceSAndroid Build Coastguard Worker                ${OUTPUT}
368*35238bceSAndroid Build Coastguard Worker            }
369*35238bceSAndroid Build Coastguard Worker        ""
370*35238bceSAndroid Build Coastguard Worker    end
371*35238bceSAndroid Build Coastguard Worker
372*35238bceSAndroid Build Coastguard Worker    case function_parameter_hides_function
373*35238bceSAndroid Build Coastguard Worker        version 100 es
374*35238bceSAndroid Build Coastguard Worker        values
375*35238bceSAndroid Build Coastguard Worker        {
376*35238bceSAndroid Build Coastguard Worker            input int in0 = [ 1 | 2 | 3 ];
377*35238bceSAndroid Build Coastguard Worker            output int out0 = [ 1 | 2 | 3 ];
378*35238bceSAndroid Build Coastguard Worker        }
379*35238bceSAndroid Build Coastguard Worker
380*35238bceSAndroid Build Coastguard Worker        both ""
381*35238bceSAndroid Build Coastguard Worker            #version 100
382*35238bceSAndroid Build Coastguard Worker            precision mediump float;
383*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
384*35238bceSAndroid Build Coastguard Worker
385*35238bceSAndroid Build Coastguard Worker            int func (int func) { return func; }
386*35238bceSAndroid Build Coastguard Worker
387*35238bceSAndroid Build Coastguard Worker            void main()
388*35238bceSAndroid Build Coastguard Worker            {
389*35238bceSAndroid Build Coastguard Worker                ${SETUP}
390*35238bceSAndroid Build Coastguard Worker                out0 = func(in0);
391*35238bceSAndroid Build Coastguard Worker                ${OUTPUT}
392*35238bceSAndroid Build Coastguard Worker            }
393*35238bceSAndroid Build Coastguard Worker        ""
394*35238bceSAndroid Build Coastguard Worker    end
395*35238bceSAndroid Build Coastguard Worker
396*35238bceSAndroid Build Coastguard Worker    case local_variable_in_inner_scope_hides_function_parameter
397*35238bceSAndroid Build Coastguard Worker        version 100 es
398*35238bceSAndroid Build Coastguard Worker        values
399*35238bceSAndroid Build Coastguard Worker        {
400*35238bceSAndroid Build Coastguard Worker            input int in0 = [ 1 | 2 | 3 ];
401*35238bceSAndroid Build Coastguard Worker            output int out0 = [ 1 | 2 | 3 ];
402*35238bceSAndroid Build Coastguard Worker        }
403*35238bceSAndroid Build Coastguard Worker
404*35238bceSAndroid Build Coastguard Worker        both ""
405*35238bceSAndroid Build Coastguard Worker            #version 100
406*35238bceSAndroid Build Coastguard Worker            precision mediump float;
407*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
408*35238bceSAndroid Build Coastguard Worker            int func (int inp, int x) { { int x = 5; return inp + x - 5; } }
409*35238bceSAndroid Build Coastguard Worker
410*35238bceSAndroid Build Coastguard Worker            void main()
411*35238bceSAndroid Build Coastguard Worker            {
412*35238bceSAndroid Build Coastguard Worker                ${SETUP}
413*35238bceSAndroid Build Coastguard Worker                out0 = func(in0, 42);
414*35238bceSAndroid Build Coastguard Worker                ${OUTPUT}
415*35238bceSAndroid Build Coastguard Worker            }
416*35238bceSAndroid Build Coastguard Worker        ""
417*35238bceSAndroid Build Coastguard Worker    end
418*35238bceSAndroid Build Coastguard Worker
419*35238bceSAndroid Build Coastguard Worker    case local_variable_hides_function_parameter
420*35238bceSAndroid Build Coastguard Worker        version 100 es
421*35238bceSAndroid Build Coastguard Worker        values
422*35238bceSAndroid Build Coastguard Worker        {
423*35238bceSAndroid Build Coastguard Worker            input int in0 = [ 1 | 2 | 3 ];
424*35238bceSAndroid Build Coastguard Worker            output int out0 = [ 1 | 2 | 3 ];
425*35238bceSAndroid Build Coastguard Worker        }
426*35238bceSAndroid Build Coastguard Worker
427*35238bceSAndroid Build Coastguard Worker        both ""
428*35238bceSAndroid Build Coastguard Worker            #version 100
429*35238bceSAndroid Build Coastguard Worker            precision mediump float;
430*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
431*35238bceSAndroid Build Coastguard Worker            int func (int inp, int x) { int x = 5; return inp + x - 5; }
432*35238bceSAndroid Build Coastguard Worker
433*35238bceSAndroid Build Coastguard Worker            void main()
434*35238bceSAndroid Build Coastguard Worker            {
435*35238bceSAndroid Build Coastguard Worker                ${SETUP}
436*35238bceSAndroid Build Coastguard Worker                out0 = func(in0, 42);
437*35238bceSAndroid Build Coastguard Worker                ${OUTPUT}
438*35238bceSAndroid Build Coastguard Worker            }
439*35238bceSAndroid Build Coastguard Worker        ""
440*35238bceSAndroid Build Coastguard Worker    end
441*35238bceSAndroid Build Coastguard Worker
442*35238bceSAndroid Build Coastguard Workerend
443*35238bceSAndroid Build Coastguard Worker
444*35238bceSAndroid Build Coastguard Workergroup invalid "Invalid scoping behavior"
445*35238bceSAndroid Build Coastguard Worker
446*35238bceSAndroid Build Coastguard Worker    case redeclare_global_variable
447*35238bceSAndroid Build Coastguard Worker        version 100 es
448*35238bceSAndroid Build Coastguard Worker        expect compile_fail
449*35238bceSAndroid Build Coastguard Worker        both ""
450*35238bceSAndroid Build Coastguard Worker            #version 100
451*35238bceSAndroid Build Coastguard Worker            precision mediump float;
452*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
453*35238bceSAndroid Build Coastguard Worker
454*35238bceSAndroid Build Coastguard Worker            int a;
455*35238bceSAndroid Build Coastguard Worker            float a;
456*35238bceSAndroid Build Coastguard Worker
457*35238bceSAndroid Build Coastguard Worker            void main()
458*35238bceSAndroid Build Coastguard Worker            {
459*35238bceSAndroid Build Coastguard Worker                a = 1.0;
460*35238bceSAndroid Build Coastguard Worker                ${POSITION_FRAG_COLOR} = vec4(a);
461*35238bceSAndroid Build Coastguard Worker            }
462*35238bceSAndroid Build Coastguard Worker        ""
463*35238bceSAndroid Build Coastguard Worker    end
464*35238bceSAndroid Build Coastguard Worker
465*35238bceSAndroid Build Coastguard Worker    case redeclare_local_variable
466*35238bceSAndroid Build Coastguard Worker        version 100 es
467*35238bceSAndroid Build Coastguard Worker        expect compile_fail
468*35238bceSAndroid Build Coastguard Worker        both ""
469*35238bceSAndroid Build Coastguard Worker            #version 100
470*35238bceSAndroid Build Coastguard Worker            precision mediump float;
471*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
472*35238bceSAndroid Build Coastguard Worker
473*35238bceSAndroid Build Coastguard Worker            void main()
474*35238bceSAndroid Build Coastguard Worker            {
475*35238bceSAndroid Build Coastguard Worker                int a;
476*35238bceSAndroid Build Coastguard Worker                float a;
477*35238bceSAndroid Build Coastguard Worker                a = 1.0;
478*35238bceSAndroid Build Coastguard Worker                ${POSITION_FRAG_COLOR} = vec4(a);
479*35238bceSAndroid Build Coastguard Worker            }
480*35238bceSAndroid Build Coastguard Worker        ""
481*35238bceSAndroid Build Coastguard Worker    end
482*35238bceSAndroid Build Coastguard Worker
483*35238bceSAndroid Build Coastguard Worker    case redeclare_for_init_statement_variable
484*35238bceSAndroid Build Coastguard Worker        version 100 es
485*35238bceSAndroid Build Coastguard Worker        expect compile_fail
486*35238bceSAndroid Build Coastguard Worker        both ""
487*35238bceSAndroid Build Coastguard Worker            #version 100
488*35238bceSAndroid Build Coastguard Worker            precision mediump float;
489*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
490*35238bceSAndroid Build Coastguard Worker
491*35238bceSAndroid Build Coastguard Worker            void main()
492*35238bceSAndroid Build Coastguard Worker            {
493*35238bceSAndroid Build Coastguard Worker                for (int i = 0; i < 10; i++)
494*35238bceSAndroid Build Coastguard Worker                {
495*35238bceSAndroid Build Coastguard Worker                    int i = 11;
496*35238bceSAndroid Build Coastguard Worker                }
497*35238bceSAndroid Build Coastguard Worker                ${POSITION_FRAG_COLOR} = vec4(0.0);
498*35238bceSAndroid Build Coastguard Worker            }
499*35238bceSAndroid Build Coastguard Worker        ""
500*35238bceSAndroid Build Coastguard Worker    end
501*35238bceSAndroid Build Coastguard Worker
502*35238bceSAndroid Build Coastguard Worker    case redeclare_for_condition_variable
503*35238bceSAndroid Build Coastguard Worker        version 100 es
504*35238bceSAndroid Build Coastguard Worker        expect compile_fail
505*35238bceSAndroid Build Coastguard Worker        both ""
506*35238bceSAndroid Build Coastguard Worker            #version 100
507*35238bceSAndroid Build Coastguard Worker            precision mediump float;
508*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
509*35238bceSAndroid Build Coastguard Worker
510*35238bceSAndroid Build Coastguard Worker            void main()
511*35238bceSAndroid Build Coastguard Worker            {
512*35238bceSAndroid Build Coastguard Worker                for (int i = 0; int a = (i < 10); i++)
513*35238bceSAndroid Build Coastguard Worker                {
514*35238bceSAndroid Build Coastguard Worker                    int a = 0;
515*35238bceSAndroid Build Coastguard Worker                }
516*35238bceSAndroid Build Coastguard Worker                ${POSITION_FRAG_COLOR} = vec4(0.0);
517*35238bceSAndroid Build Coastguard Worker            }
518*35238bceSAndroid Build Coastguard Worker        ""
519*35238bceSAndroid Build Coastguard Worker    end
520*35238bceSAndroid Build Coastguard Worker
521*35238bceSAndroid Build Coastguard Worker    case redeclare_for_init_statement_variable_in_for_condition
522*35238bceSAndroid Build Coastguard Worker        version 100 es
523*35238bceSAndroid Build Coastguard Worker        expect compile_fail
524*35238bceSAndroid Build Coastguard Worker        both ""
525*35238bceSAndroid Build Coastguard Worker            #version 100
526*35238bceSAndroid Build Coastguard Worker            precision mediump float;
527*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
528*35238bceSAndroid Build Coastguard Worker
529*35238bceSAndroid Build Coastguard Worker            void main()
530*35238bceSAndroid Build Coastguard Worker            {
531*35238bceSAndroid Build Coastguard Worker                float a;
532*35238bceSAndroid Build Coastguard Worker                for (int i = 0; int i = (i < 10); i++)
533*35238bceSAndroid Build Coastguard Worker                {
534*35238bceSAndroid Build Coastguard Worker                    a = sin(i);
535*35238bceSAndroid Build Coastguard Worker                }
536*35238bceSAndroid Build Coastguard Worker                ${POSITION_FRAG_COLOR} = vec4(a);
537*35238bceSAndroid Build Coastguard Worker            }
538*35238bceSAndroid Build Coastguard Worker        ""
539*35238bceSAndroid Build Coastguard Worker    end
540*35238bceSAndroid Build Coastguard Worker
541*35238bceSAndroid Build Coastguard Worker    case redeclare_while_condition_variable
542*35238bceSAndroid Build Coastguard Worker        version 100 es
543*35238bceSAndroid Build Coastguard Worker        expect compile_fail
544*35238bceSAndroid Build Coastguard Worker        both ""
545*35238bceSAndroid Build Coastguard Worker            #version 100
546*35238bceSAndroid Build Coastguard Worker            precision mediump float;
547*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
548*35238bceSAndroid Build Coastguard Worker
549*35238bceSAndroid Build Coastguard Worker            void main()
550*35238bceSAndroid Build Coastguard Worker            {
551*35238bceSAndroid Build Coastguard Worker                int a = 0;
552*35238bceSAndroid Build Coastguard Worker                while (int i = (a < 5))
553*35238bceSAndroid Build Coastguard Worker                {
554*35238bceSAndroid Build Coastguard Worker                    int i = 11;
555*35238bceSAndroid Build Coastguard Worker                    a += i;
556*35238bceSAndroid Build Coastguard Worker                }
557*35238bceSAndroid Build Coastguard Worker                ${POSITION_FRAG_COLOR} = vec4(0.0);
558*35238bceSAndroid Build Coastguard Worker            }
559*35238bceSAndroid Build Coastguard Worker        ""
560*35238bceSAndroid Build Coastguard Worker    end
561*35238bceSAndroid Build Coastguard Worker
562*35238bceSAndroid Build Coastguard Worker    case redeclare_function
563*35238bceSAndroid Build Coastguard Worker        version 100 es
564*35238bceSAndroid Build Coastguard Worker        expect compile_fail
565*35238bceSAndroid Build Coastguard Worker        both ""
566*35238bceSAndroid Build Coastguard Worker            #version 100
567*35238bceSAndroid Build Coastguard Worker            precision mediump float;
568*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
569*35238bceSAndroid Build Coastguard Worker
570*35238bceSAndroid Build Coastguard Worker            float func(float x);
571*35238bceSAndroid Build Coastguard Worker            float func(float x);
572*35238bceSAndroid Build Coastguard Worker
573*35238bceSAndroid Build Coastguard Worker            float func(float x) { return x + 1.0; }
574*35238bceSAndroid Build Coastguard Worker
575*35238bceSAndroid Build Coastguard Worker            void main()
576*35238bceSAndroid Build Coastguard Worker            {
577*35238bceSAndroid Build Coastguard Worker                ${POSITION_FRAG_COLOR} = vec4(func(1.0));
578*35238bceSAndroid Build Coastguard Worker            }
579*35238bceSAndroid Build Coastguard Worker        ""
580*35238bceSAndroid Build Coastguard Worker    end
581*35238bceSAndroid Build Coastguard Worker
582*35238bceSAndroid Build Coastguard Worker    case redefine_function
583*35238bceSAndroid Build Coastguard Worker        version 100 es
584*35238bceSAndroid Build Coastguard Worker        expect compile_fail
585*35238bceSAndroid Build Coastguard Worker        both ""
586*35238bceSAndroid Build Coastguard Worker            #version 100
587*35238bceSAndroid Build Coastguard Worker            precision mediump float;
588*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
589*35238bceSAndroid Build Coastguard Worker
590*35238bceSAndroid Build Coastguard Worker            float func(float x);
591*35238bceSAndroid Build Coastguard Worker
592*35238bceSAndroid Build Coastguard Worker            float func(float x) { return x + 1.0; }
593*35238bceSAndroid Build Coastguard Worker            float func(float x) { return x + 2.0; }
594*35238bceSAndroid Build Coastguard Worker
595*35238bceSAndroid Build Coastguard Worker            void main()
596*35238bceSAndroid Build Coastguard Worker            {
597*35238bceSAndroid Build Coastguard Worker                ${POSITION_FRAG_COLOR} = vec4(func(1.0));
598*35238bceSAndroid Build Coastguard Worker            }
599*35238bceSAndroid Build Coastguard Worker        ""
600*35238bceSAndroid Build Coastguard Worker    end
601*35238bceSAndroid Build Coastguard Worker
602*35238bceSAndroid Build Coastguard Worker    case redeclare_builtin
603*35238bceSAndroid Build Coastguard Worker        version 100 es
604*35238bceSAndroid Build Coastguard Worker        expect compile_fail
605*35238bceSAndroid Build Coastguard Worker        both ""
606*35238bceSAndroid Build Coastguard Worker            #version 100
607*35238bceSAndroid Build Coastguard Worker            precision mediump float;
608*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
609*35238bceSAndroid Build Coastguard Worker
610*35238bceSAndroid Build Coastguard Worker            float sin(float x);
611*35238bceSAndroid Build Coastguard Worker
612*35238bceSAndroid Build Coastguard Worker            void main()
613*35238bceSAndroid Build Coastguard Worker            {
614*35238bceSAndroid Build Coastguard Worker                ${POSITION_FRAG_COLOR} = vec4(sin(1.0));
615*35238bceSAndroid Build Coastguard Worker            }
616*35238bceSAndroid Build Coastguard Worker        ""
617*35238bceSAndroid Build Coastguard Worker    end
618*35238bceSAndroid Build Coastguard Worker
619*35238bceSAndroid Build Coastguard Worker    case redefine_builtin
620*35238bceSAndroid Build Coastguard Worker        version 100 es
621*35238bceSAndroid Build Coastguard Worker        expect compile_fail
622*35238bceSAndroid Build Coastguard Worker        both ""
623*35238bceSAndroid Build Coastguard Worker            #version 100
624*35238bceSAndroid Build Coastguard Worker            precision mediump float;
625*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
626*35238bceSAndroid Build Coastguard Worker
627*35238bceSAndroid Build Coastguard Worker            float sin(float x) { return x + 1.0; }
628*35238bceSAndroid Build Coastguard Worker
629*35238bceSAndroid Build Coastguard Worker            void main()
630*35238bceSAndroid Build Coastguard Worker            {
631*35238bceSAndroid Build Coastguard Worker                ${POSITION_FRAG_COLOR} = vec4(sin(1.0));
632*35238bceSAndroid Build Coastguard Worker            }
633*35238bceSAndroid Build Coastguard Worker        ""
634*35238bceSAndroid Build Coastguard Worker    end
635*35238bceSAndroid Build Coastguard Worker
636*35238bceSAndroid Build Coastguard Worker    case conflict_function_struct
637*35238bceSAndroid Build Coastguard Worker        version 100 es
638*35238bceSAndroid Build Coastguard Worker        expect compile_fail
639*35238bceSAndroid Build Coastguard Worker        both ""
640*35238bceSAndroid Build Coastguard Worker            #version 100
641*35238bceSAndroid Build Coastguard Worker            precision mediump float;
642*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
643*35238bceSAndroid Build Coastguard Worker
644*35238bceSAndroid Build Coastguard Worker            void f(int x);
645*35238bceSAndroid Build Coastguard Worker            struct f { int x; };
646*35238bceSAndroid Build Coastguard Worker
647*35238bceSAndroid Build Coastguard Worker            void main()
648*35238bceSAndroid Build Coastguard Worker            {
649*35238bceSAndroid Build Coastguard Worker                ${POSITION_FRAG_COLOR} = vec4(1);
650*35238bceSAndroid Build Coastguard Worker            }
651*35238bceSAndroid Build Coastguard Worker        ""
652*35238bceSAndroid Build Coastguard Worker    end
653*35238bceSAndroid Build Coastguard Worker
654*35238bceSAndroid Build Coastguard Worker    case conflict_function_variable
655*35238bceSAndroid Build Coastguard Worker        version 100 es
656*35238bceSAndroid Build Coastguard Worker        expect compile_fail
657*35238bceSAndroid Build Coastguard Worker        both ""
658*35238bceSAndroid Build Coastguard Worker            #version 100
659*35238bceSAndroid Build Coastguard Worker            precision mediump float;
660*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
661*35238bceSAndroid Build Coastguard Worker
662*35238bceSAndroid Build Coastguard Worker            void f(int x);
663*35238bceSAndroid Build Coastguard Worker            float f;
664*35238bceSAndroid Build Coastguard Worker
665*35238bceSAndroid Build Coastguard Worker            void main()
666*35238bceSAndroid Build Coastguard Worker            {
667*35238bceSAndroid Build Coastguard Worker                f = 1.0;
668*35238bceSAndroid Build Coastguard Worker                ${POSITION_FRAG_COLOR} = vec4(f);
669*35238bceSAndroid Build Coastguard Worker            }
670*35238bceSAndroid Build Coastguard Worker        ""
671*35238bceSAndroid Build Coastguard Worker    end
672*35238bceSAndroid Build Coastguard Worker
673*35238bceSAndroid Build Coastguard Worker    case use_global_variable_before_declaration
674*35238bceSAndroid Build Coastguard Worker        version 100 es
675*35238bceSAndroid Build Coastguard Worker        expect compile_fail
676*35238bceSAndroid Build Coastguard Worker        both ""
677*35238bceSAndroid Build Coastguard Worker            #version 100
678*35238bceSAndroid Build Coastguard Worker            precision mediump float;
679*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
680*35238bceSAndroid Build Coastguard Worker
681*35238bceSAndroid Build Coastguard Worker            void func()
682*35238bceSAndroid Build Coastguard Worker            {
683*35238bceSAndroid Build Coastguard Worker                a = 2.0;
684*35238bceSAndroid Build Coastguard Worker            }
685*35238bceSAndroid Build Coastguard Worker
686*35238bceSAndroid Build Coastguard Worker            float a;
687*35238bceSAndroid Build Coastguard Worker
688*35238bceSAndroid Build Coastguard Worker            void main()
689*35238bceSAndroid Build Coastguard Worker            {
690*35238bceSAndroid Build Coastguard Worker                func();
691*35238bceSAndroid Build Coastguard Worker                ${POSITION_FRAG_COLOR} = vec4(a);
692*35238bceSAndroid Build Coastguard Worker            }
693*35238bceSAndroid Build Coastguard Worker        ""
694*35238bceSAndroid Build Coastguard Worker    end
695*35238bceSAndroid Build Coastguard Worker
696*35238bceSAndroid Build Coastguard Worker    case use_local_variable_before_declaration
697*35238bceSAndroid Build Coastguard Worker        version 100 es
698*35238bceSAndroid Build Coastguard Worker        expect compile_fail
699*35238bceSAndroid Build Coastguard Worker        both ""
700*35238bceSAndroid Build Coastguard Worker            #version 100
701*35238bceSAndroid Build Coastguard Worker            precision mediump float;
702*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
703*35238bceSAndroid Build Coastguard Worker
704*35238bceSAndroid Build Coastguard Worker            void main()
705*35238bceSAndroid Build Coastguard Worker            {
706*35238bceSAndroid Build Coastguard Worker                float a = 1.0;
707*35238bceSAndroid Build Coastguard Worker                a = b;
708*35238bceSAndroid Build Coastguard Worker                float b = 2.0;
709*35238bceSAndroid Build Coastguard Worker
710*35238bceSAndroid Build Coastguard Worker                ${POSITION_FRAG_COLOR} = vec4(a);
711*35238bceSAndroid Build Coastguard Worker            }
712*35238bceSAndroid Build Coastguard Worker        ""
713*35238bceSAndroid Build Coastguard Worker    end
714*35238bceSAndroid Build Coastguard Worker
715*35238bceSAndroid Build Coastguard Worker    case use_struct_type_before_declaration
716*35238bceSAndroid Build Coastguard Worker        version 100 es
717*35238bceSAndroid Build Coastguard Worker        expect compile_fail
718*35238bceSAndroid Build Coastguard Worker        both ""
719*35238bceSAndroid Build Coastguard Worker            #version 100
720*35238bceSAndroid Build Coastguard Worker            precision mediump float;
721*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
722*35238bceSAndroid Build Coastguard Worker
723*35238bceSAndroid Build Coastguard Worker            float func (float x) { return S(x).val; }
724*35238bceSAndroid Build Coastguard Worker            struct S { float val; };
725*35238bceSAndroid Build Coastguard Worker
726*35238bceSAndroid Build Coastguard Worker            void main()
727*35238bceSAndroid Build Coastguard Worker            {
728*35238bceSAndroid Build Coastguard Worker                ${POSITION_FRAG_COLOR} = vec4(func(1.0));
729*35238bceSAndroid Build Coastguard Worker            }
730*35238bceSAndroid Build Coastguard Worker        ""
731*35238bceSAndroid Build Coastguard Worker    end
732*35238bceSAndroid Build Coastguard Worker
733*35238bceSAndroid Build Coastguard Worker    case use_function_before_declaration
734*35238bceSAndroid Build Coastguard Worker        version 100 es
735*35238bceSAndroid Build Coastguard Worker        expect compile_fail
736*35238bceSAndroid Build Coastguard Worker        both ""
737*35238bceSAndroid Build Coastguard Worker            #version 100
738*35238bceSAndroid Build Coastguard Worker            precision mediump float;
739*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
740*35238bceSAndroid Build Coastguard Worker
741*35238bceSAndroid Build Coastguard Worker            float func (float x) { return bar(x); }
742*35238bceSAndroid Build Coastguard Worker            float bar (float x) { return x; }
743*35238bceSAndroid Build Coastguard Worker
744*35238bceSAndroid Build Coastguard Worker            void main()
745*35238bceSAndroid Build Coastguard Worker            {
746*35238bceSAndroid Build Coastguard Worker                ${POSITION_FRAG_COLOR} = vec4(func(1.0));
747*35238bceSAndroid Build Coastguard Worker            }
748*35238bceSAndroid Build Coastguard Worker        ""
749*35238bceSAndroid Build Coastguard Worker    end
750*35238bceSAndroid Build Coastguard Worker
751*35238bceSAndroid Build Coastguard Worker    case use_variable_from_block_in_outer_scope
752*35238bceSAndroid Build Coastguard Worker        version 100 es
753*35238bceSAndroid Build Coastguard Worker        expect compile_fail
754*35238bceSAndroid Build Coastguard Worker        both ""
755*35238bceSAndroid Build Coastguard Worker            #version 100
756*35238bceSAndroid Build Coastguard Worker            precision mediump float;
757*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
758*35238bceSAndroid Build Coastguard Worker
759*35238bceSAndroid Build Coastguard Worker            void main()
760*35238bceSAndroid Build Coastguard Worker            {
761*35238bceSAndroid Build Coastguard Worker                {
762*35238bceSAndroid Build Coastguard Worker                    float a = 1.0;
763*35238bceSAndroid Build Coastguard Worker                }
764*35238bceSAndroid Build Coastguard Worker                ${POSITION_FRAG_COLOR} = vec4(a);
765*35238bceSAndroid Build Coastguard Worker            }
766*35238bceSAndroid Build Coastguard Worker        ""
767*35238bceSAndroid Build Coastguard Worker    end
768*35238bceSAndroid Build Coastguard Worker
769*35238bceSAndroid Build Coastguard Worker    case use_variable_from_if_in_outer_scope
770*35238bceSAndroid Build Coastguard Worker        version 100 es
771*35238bceSAndroid Build Coastguard Worker        expect compile_fail
772*35238bceSAndroid Build Coastguard Worker        both ""
773*35238bceSAndroid Build Coastguard Worker            #version 100
774*35238bceSAndroid Build Coastguard Worker            precision mediump float;
775*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
776*35238bceSAndroid Build Coastguard Worker
777*35238bceSAndroid Build Coastguard Worker            void main()
778*35238bceSAndroid Build Coastguard Worker            {
779*35238bceSAndroid Build Coastguard Worker                if (true)
780*35238bceSAndroid Build Coastguard Worker                    float a = 1.0;
781*35238bceSAndroid Build Coastguard Worker                ${POSITION_FRAG_COLOR} = vec4(a);
782*35238bceSAndroid Build Coastguard Worker            }
783*35238bceSAndroid Build Coastguard Worker        ""
784*35238bceSAndroid Build Coastguard Worker    end
785*35238bceSAndroid Build Coastguard Worker
786*35238bceSAndroid Build Coastguard Worker    case use_variable_from_else_in_outer_scope
787*35238bceSAndroid Build Coastguard Worker        version 100 es
788*35238bceSAndroid Build Coastguard Worker        expect compile_fail
789*35238bceSAndroid Build Coastguard Worker        both ""
790*35238bceSAndroid Build Coastguard Worker            #version 100
791*35238bceSAndroid Build Coastguard Worker            precision mediump float;
792*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
793*35238bceSAndroid Build Coastguard Worker
794*35238bceSAndroid Build Coastguard Worker            void main()
795*35238bceSAndroid Build Coastguard Worker            {
796*35238bceSAndroid Build Coastguard Worker                if (false)
797*35238bceSAndroid Build Coastguard Worker                    float a = 1.0;
798*35238bceSAndroid Build Coastguard Worker                else
799*35238bceSAndroid Build Coastguard Worker                    float b = 2.0;
800*35238bceSAndroid Build Coastguard Worker                ${POSITION_FRAG_COLOR} = vec4(b);
801*35238bceSAndroid Build Coastguard Worker            }
802*35238bceSAndroid Build Coastguard Worker        ""
803*35238bceSAndroid Build Coastguard Worker    end
804*35238bceSAndroid Build Coastguard Worker
805*35238bceSAndroid Build Coastguard Worker    case use_variable_from_if_in_else
806*35238bceSAndroid Build Coastguard Worker        version 100 es
807*35238bceSAndroid Build Coastguard Worker        expect compile_fail
808*35238bceSAndroid Build Coastguard Worker        both ""
809*35238bceSAndroid Build Coastguard Worker            #version 100
810*35238bceSAndroid Build Coastguard Worker            precision mediump float;
811*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
812*35238bceSAndroid Build Coastguard Worker
813*35238bceSAndroid Build Coastguard Worker            void main()
814*35238bceSAndroid Build Coastguard Worker            {
815*35238bceSAndroid Build Coastguard Worker                float a = 1.0;
816*35238bceSAndroid Build Coastguard Worker                if (true)
817*35238bceSAndroid Build Coastguard Worker                {
818*35238bceSAndroid Build Coastguard Worker                    float b = 2.0;
819*35238bceSAndroid Build Coastguard Worker                }
820*35238bceSAndroid Build Coastguard Worker                else
821*35238bceSAndroid Build Coastguard Worker                {
822*35238bceSAndroid Build Coastguard Worker                    a = b;
823*35238bceSAndroid Build Coastguard Worker                }
824*35238bceSAndroid Build Coastguard Worker                ${POSITION_FRAG_COLOR} = vec4(a);
825*35238bceSAndroid Build Coastguard Worker            }
826*35238bceSAndroid Build Coastguard Worker        ""
827*35238bceSAndroid Build Coastguard Worker    end
828*35238bceSAndroid Build Coastguard Worker
829*35238bceSAndroid Build Coastguard Worker    case use_variable_from_for_init_statement_in_outer_scope
830*35238bceSAndroid Build Coastguard Worker        version 100 es
831*35238bceSAndroid Build Coastguard Worker        expect compile_fail
832*35238bceSAndroid Build Coastguard Worker        both ""
833*35238bceSAndroid Build Coastguard Worker            #version 100
834*35238bceSAndroid Build Coastguard Worker            precision mediump float;
835*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
836*35238bceSAndroid Build Coastguard Worker
837*35238bceSAndroid Build Coastguard Worker            void main()
838*35238bceSAndroid Build Coastguard Worker            {
839*35238bceSAndroid Build Coastguard Worker                float x = 0.0;
840*35238bceSAndroid Build Coastguard Worker                for (int i = 0; i < 10; i++)
841*35238bceSAndroid Build Coastguard Worker                {
842*35238bceSAndroid Build Coastguard Worker                    x += sin(i);
843*35238bceSAndroid Build Coastguard Worker                }
844*35238bceSAndroid Build Coastguard Worker                ${POSITION_FRAG_COLOR} = vec4(float(i));
845*35238bceSAndroid Build Coastguard Worker            }
846*35238bceSAndroid Build Coastguard Worker        ""
847*35238bceSAndroid Build Coastguard Worker    end
848*35238bceSAndroid Build Coastguard Worker
849*35238bceSAndroid Build Coastguard Worker    case use_variable_from_while_condition_in_outer_scope
850*35238bceSAndroid Build Coastguard Worker        version 100 es
851*35238bceSAndroid Build Coastguard Worker        expect compile_fail
852*35238bceSAndroid Build Coastguard Worker        both ""
853*35238bceSAndroid Build Coastguard Worker            #version 100
854*35238bceSAndroid Build Coastguard Worker            precision mediump float;
855*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
856*35238bceSAndroid Build Coastguard Worker
857*35238bceSAndroid Build Coastguard Worker            void main()
858*35238bceSAndroid Build Coastguard Worker            {
859*35238bceSAndroid Build Coastguard Worker                int a = 1;
860*35238bceSAndroid Build Coastguard Worker                while (bool b = (a == 1))
861*35238bceSAndroid Build Coastguard Worker                {
862*35238bceSAndroid Build Coastguard Worker                    a++;
863*35238bceSAndroid Build Coastguard Worker                }
864*35238bceSAndroid Build Coastguard Worker                ${POSITION_FRAG_COLOR} = vec4(float(b));
865*35238bceSAndroid Build Coastguard Worker            }
866*35238bceSAndroid Build Coastguard Worker        ""
867*35238bceSAndroid Build Coastguard Worker    end
868*35238bceSAndroid Build Coastguard Worker
869*35238bceSAndroid Build Coastguard Worker    case use_parameter_names_from_function_declaration
870*35238bceSAndroid Build Coastguard Worker        version 100 es
871*35238bceSAndroid Build Coastguard Worker        expect compile_fail
872*35238bceSAndroid Build Coastguard Worker        both ""
873*35238bceSAndroid Build Coastguard Worker            #version 100
874*35238bceSAndroid Build Coastguard Worker            precision mediump float;
875*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
876*35238bceSAndroid Build Coastguard Worker
877*35238bceSAndroid Build Coastguard Worker            float func(float a, float b);
878*35238bceSAndroid Build Coastguard Worker
879*35238bceSAndroid Build Coastguard Worker            float func(float x, float y) { return a+b; }
880*35238bceSAndroid Build Coastguard Worker
881*35238bceSAndroid Build Coastguard Worker            void main()
882*35238bceSAndroid Build Coastguard Worker            {
883*35238bceSAndroid Build Coastguard Worker                ${POSITION_FRAG_COLOR} = vec4(func(1.0, 2.0));
884*35238bceSAndroid Build Coastguard Worker            }
885*35238bceSAndroid Build Coastguard Worker        ""
886*35238bceSAndroid Build Coastguard Worker    end
887*35238bceSAndroid Build Coastguard Worker
888*35238bceSAndroid Build Coastguard Worker    case variable_not_visible_in_own_initializer
889*35238bceSAndroid Build Coastguard Worker        version 100 es
890*35238bceSAndroid Build Coastguard Worker        expect compile_fail
891*35238bceSAndroid Build Coastguard Worker        both ""
892*35238bceSAndroid Build Coastguard Worker            #version 100
893*35238bceSAndroid Build Coastguard Worker            precision mediump float;
894*35238bceSAndroid Build Coastguard Worker            ${DECLARATIONS}
895*35238bceSAndroid Build Coastguard Worker
896*35238bceSAndroid Build Coastguard Worker            void main()
897*35238bceSAndroid Build Coastguard Worker            {
898*35238bceSAndroid Build Coastguard Worker                float x = x;
899*35238bceSAndroid Build Coastguard Worker                ${POSITION_FRAG_COLOR} = vec4(x);
900*35238bceSAndroid Build Coastguard Worker            }
901*35238bceSAndroid Build Coastguard Worker        ""
902*35238bceSAndroid Build Coastguard Worker    end
903*35238bceSAndroid Build Coastguard Worker
904*35238bceSAndroid Build Coastguard Workerend # invalid
905