[Mesa-dev] [PATCH 02/17] glsl: Add function parameter declarations to the symbol table

Samuel Iglesias Gonsalvez siglesias at igalia.com
Wed Jul 29 07:01:19 PDT 2015


From: Iago Toral Quiroga <itoral at igalia.com>

So they can hide declarations with the same name in other scopes.
Otherwise we get a parsing error for things like:

struct S { int val; };
int func (int S) { return S; }

Fixes the following 2 dEQP tests:
dEQP-GLES3.functional.shaders.scoping.valid.function_parameter_hides_struct_type_vertex
dEQP-GLES3.functional.shaders.scoping.valid.function_parameter_hides_struct_type_fragment
---
 src/glsl/glsl_parser.yy | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 38b560d..e66b80a 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -876,6 +876,7 @@ parameter_declarator:
       $$->type->set_location(@1);
       $$->type->specifier = $1;
       $$->identifier = $2;
+      state->symbols->add_variable(new(state) ir_variable(NULL, $2, ir_var_auto));
    }
    | type_specifier any_identifier array_specifier
    {
@@ -887,6 +888,7 @@ parameter_declarator:
       $$->type->specifier = $1;
       $$->identifier = $2;
       $$->array_specifier = $3;
+      state->symbols->add_variable(new(state) ir_variable(NULL, $2, ir_var_auto));
    }
    ;
 
-- 
2.4.3



More information about the mesa-dev mailing list