1 group valid "Valid scoping and name redeclaration cases"
3 case local_variable_hides_global_variable
7 input int in0 = [ 1 | 2 | 3 ];
8 output int out0 = [ 1 | 2 | 3 ];
13 precision mediump float;
29 case block_variable_hides_local_variable
33 input int in0 = [ 1 | 2 | 3 ];
34 output int out0 = [ 1 | 2 | 3 ];
39 precision mediump float;
54 case block_variable_hides_global_variable
58 input int in0 = [ 1 | 2 | 3 ];
59 output int out0 = [ 1 | 2 | 3 ];
64 precision mediump float;
82 case for_init_statement_variable_hides_local_variable
86 input int in0 = [ 1 | 2 | 3 ];
87 output int out0 = [ 1 | 2 | 3 ];
92 precision mediump float;
98 for (int a = 0; a < 10; a++)
107 case while_condition_variable_hides_local_variable
109 require full_glsl_es_100_support
112 input int in0 = [ 1 | 2 | 3 ];
113 output int out0 = [ 1 | 2 | 3 ];
118 precision mediump float;
125 while (bool a = (i < 1))
135 case for_init_statement_variable_hides_global_variable
139 input int in0 = [ 1 | 2 | 3 ];
140 output int out0 = [ 1 | 2 | 3 ];
145 precision mediump float;
153 for (int a = 0; a < 10; a++)
162 case while_condition_variable_hides_global_variable
164 require full_glsl_es_100_support
167 input int in0 = [ 1 | 2 | 3 ];
168 output int out0 = [ 1 | 2 | 3 ];
173 precision mediump float;
182 while (bool a = (i < 1))
192 case variable_in_if_hides_global_variable
196 input int in0 = [ 1 | 2 | 3 ];
197 output int out0 = [ 1 | 2 | 3 ];
202 precision mediump float;
218 case variable_from_outer_scope_visible_in_initializer
222 input int in0 = [ 1 | 2 | 3 ];
223 output int out0 = [ 1 | 2 | 3 ];
228 precision mediump float;
235 int a = a+5, b = a-5;
239 out0 = out0 + a - in0;
245 case local_int_variable_hides_struct_type
249 input int in0 = [ 1 | 2 | 3 ];
250 output int out0 = [ 1 | 2 | 3 ];
255 precision mediump float;
258 struct S { int val; };
270 case local_struct_variable_hides_struct_type
274 input int in0 = [ 1 | 2 | 3 ];
275 output int out0 = [ 1 | 2 | 3 ];
280 precision mediump float;
283 struct S { int val; };
295 case local_variable_hides_function
299 input int in0 = [ 1 | 2 | 3 ];
300 output int out0 = [ 1 | 2 | 3 ];
305 precision mediump float;
308 int foo (int x) { return x; }
320 case function_parameter_hides_global_variable
324 input int in0 = [ 1 | 2 | 3 ];
325 output int out0 = [ 1 | 2 | 3 ];
330 precision mediump float;
335 int func (int a) { return a; }
346 case function_parameter_hides_struct_type
350 input int in0 = [ 1 | 2 | 3 ];
351 output int out0 = [ 1 | 2 | 3 ];
356 precision mediump float;
361 int func (int S) { return S; }
372 case function_parameter_hides_function
376 input int in0 = [ 1 | 2 | 3 ];
377 output int out0 = [ 1 | 2 | 3 ];
382 precision mediump float;
385 int func (int func) { return func; }
396 case local_variable_in_inner_scope_hides_function_parameter
400 input int in0 = [ 1 | 2 | 3 ];
401 output int out0 = [ 1 | 2 | 3 ];
406 precision mediump float;
408 int func (int inp, int x) { { int x = 5; return inp + x - 5; } }
413 out0 = func(in0, 42);
419 case local_variable_hides_function_parameter
423 input int in0 = [ 1 | 2 | 3 ];
424 output int out0 = [ 1 | 2 | 3 ];
429 precision mediump float;
431 int func (int inp, int x) { int x = 5; return inp + x - 5; }
436 out0 = func(in0, 42);
444 group invalid "Invalid scoping behavior"
446 case redeclare_global_variable
451 precision mediump float;
460 ${POSITION_FRAG_COLOR} = vec4(a);
465 case redeclare_local_variable
470 precision mediump float;
478 ${POSITION_FRAG_COLOR} = vec4(a);
483 case redeclare_for_init_statement_variable
488 precision mediump float;
493 for (int i = 0; i < 10; i++)
497 ${POSITION_FRAG_COLOR} = vec4(0.0);
502 case redeclare_for_condition_variable
507 precision mediump float;
512 for (int i = 0; int a = (i < 10); i++)
516 ${POSITION_FRAG_COLOR} = vec4(0.0);
521 case redeclare_for_init_statement_variable_in_for_condition
526 precision mediump float;
532 for (int i = 0; int i = (i < 10); i++)
536 ${POSITION_FRAG_COLOR} = vec4(a);
541 case redeclare_while_condition_variable
546 precision mediump float;
552 while (int i = (a < 5))
557 ${POSITION_FRAG_COLOR} = vec4(0.0);
562 case redeclare_function
567 precision mediump float;
573 float func(float x) { return x + 1.0; }
577 ${POSITION_FRAG_COLOR} = vec4(func(1.0));
582 case redefine_function
587 precision mediump float;
592 float func(float x) { return x + 1.0; }
593 float func(float x) { return x + 2.0; }
597 ${POSITION_FRAG_COLOR} = vec4(func(1.0));
602 case redeclare_builtin
607 precision mediump float;
614 ${POSITION_FRAG_COLOR} = vec4(sin(1.0));
619 case redefine_builtin
624 precision mediump float;
627 float sin(float x) { return x + 1.0; }
631 ${POSITION_FRAG_COLOR} = vec4(sin(1.0));
636 case conflict_function_struct
641 precision mediump float;
649 ${POSITION_FRAG_COLOR} = vec4(1);
654 case conflict_function_variable
659 precision mediump float;
668 ${POSITION_FRAG_COLOR} = vec4(f);
673 case use_global_variable_before_declaration
678 precision mediump float;
691 ${POSITION_FRAG_COLOR} = vec4(a);
696 case use_local_variable_before_declaration
701 precision mediump float;
710 ${POSITION_FRAG_COLOR} = vec4(a);
715 case use_struct_type_before_declaration
720 precision mediump float;
723 float func (float x) { return S(x).val; }
724 struct S { float val; };
728 ${POSITION_FRAG_COLOR} = vec4(func(1.0));
733 case use_function_before_declaration
738 precision mediump float;
741 float func (float x) { return bar(x); }
742 float bar (float x) { return x; }
746 ${POSITION_FRAG_COLOR} = vec4(func(1.0));
751 case use_variable_from_block_in_outer_scope
756 precision mediump float;
764 ${POSITION_FRAG_COLOR} = vec4(a);
769 case use_variable_from_if_in_outer_scope
774 precision mediump float;
781 ${POSITION_FRAG_COLOR} = vec4(a);
786 case use_variable_from_else_in_outer_scope
791 precision mediump float;
800 ${POSITION_FRAG_COLOR} = vec4(b);
805 case use_variable_from_if_in_else
810 precision mediump float;
824 ${POSITION_FRAG_COLOR} = vec4(a);
829 case use_variable_from_for_init_statement_in_outer_scope
834 precision mediump float;
840 for (int i = 0; i < 10; i++)
844 ${POSITION_FRAG_COLOR} = vec4(float(i));
849 case use_variable_from_while_condition_in_outer_scope
854 precision mediump float;
860 while (bool b = (a == 1))
864 ${POSITION_FRAG_COLOR} = vec4(float(b));
869 case use_parameter_names_from_function_declaration
874 precision mediump float;
877 float func(float a, float b);
879 float func(float x, float y) { return a+b; }
883 ${POSITION_FRAG_COLOR} = vec4(func(1.0, 2.0));
888 case variable_not_visible_in_own_initializer
893 precision mediump float;
899 ${POSITION_FRAG_COLOR} = vec4(x);