From: Iago Toral Quiroga <ito...@igalia.com>

We were doing this for all variables in a declaration list, but not
when there was just a single declaration. As a consequence, when we
used a single variable declaration to redeclare a type that existed
in a previous scope we would get a parsing error, so this would work:

struct S { int val; };
void main()
{
   int Z, S;
   S = 1;
}

but this wouldn't:

struct S { int val; };
void main()
{
   int S;
   S = 1;
}

Fixes the following 4 dEQP tests:
dEQP-GLES3.functional.shaders.scoping.valid.local_int_variable_hides_struct_type_vertex
dEQP-GLES3.functional.shaders.scoping.valid.local_int_variable_hides_struct_type_fragment
dEQP-GLES3.functional.shaders.scoping.valid.local_struct_variable_hides_struct_type_vertex
dEQP-GLES3.functional.shaders.scoping.valid.local_struct_variable_hides_struct_type_fragment
---
 src/glsl/glsl_parser.yy | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 2b0c8bd..38b560d 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -1043,6 +1043,7 @@ single_declaration:
       $$ = new(ctx) ast_declarator_list($1);
       $$->set_location_range(@1, @2);
       $$->declarations.push_tail(&decl->link);
+      state->symbols->add_variable(new(state) ir_variable(NULL, $2, 
ir_var_auto));
    }
    | fully_specified_type any_identifier array_specifier
    {
@@ -1053,6 +1054,7 @@ single_declaration:
       $$ = new(ctx) ast_declarator_list($1);
       $$->set_location_range(@1, @3);
       $$->declarations.push_tail(&decl->link);
+      state->symbols->add_variable(new(state) ir_variable(NULL, $2, 
ir_var_auto));
    }
    | fully_specified_type any_identifier array_specifier '=' initializer
    {
@@ -1063,6 +1065,7 @@ single_declaration:
       $$ = new(ctx) ast_declarator_list($1);
       $$->set_location_range(@1, @3);
       $$->declarations.push_tail(&decl->link);
+      state->symbols->add_variable(new(state) ir_variable(NULL, $2, 
ir_var_auto));
    }
    | fully_specified_type any_identifier '=' initializer
    {
@@ -1073,6 +1076,7 @@ single_declaration:
       $$ = new(ctx) ast_declarator_list($1);
       $$->set_location_range(@1, @2);
       $$->declarations.push_tail(&decl->link);
+      state->symbols->add_variable(new(state) ir_variable(NULL, $2, 
ir_var_auto));
    }
    | INVARIANT variable_identifier
    {
@@ -1085,6 +1089,7 @@ single_declaration:
       $$->invariant = true;
 
       $$->declarations.push_tail(&decl->link);
+      state->symbols->add_variable(new(state) ir_variable(NULL, $2, 
ir_var_auto));
    }
    | PRECISE variable_identifier
    {
@@ -1097,6 +1102,7 @@ single_declaration:
       $$->precise = true;
 
       $$->declarations.push_tail(&decl->link);
+      state->symbols->add_variable(new(state) ir_variable(NULL, $2, 
ir_var_auto));
    }
    ;
 
-- 
2.4.3

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to