From: Kenneth Graunke Date: Sat, 5 Mar 2016 05:19:49 +0000 (-0800) Subject: glsl: Add function parameters to the parser symbol table. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=af41c0b7e05f8d2b4b01a1a178b2bfa209236bfe;p=mesa.git glsl: Add function parameters to the parser symbol table. In a shader such as: struct S { float f; } float identity(float S) { return S; } we would think that "S" in "return S" referred to a structure, even though it's shadowed by the "float S" parameter in the inner struct. This led to the parser's grammar seeing TYPE_IDENTIFIER and getting confused. Fixes dEQP-GLES2.functional.shaders.scoping.valid. function_parameter_hides_struct_type_{vertex,fragment}. Signed-off-by: Kenneth Graunke Reviewed-by: Timothy Arceri --- diff --git a/src/compiler/glsl/glsl_parser.yy b/src/compiler/glsl/glsl_parser.yy index 78a4e5df7cf..5ed051a6705 100644 --- a/src/compiler/glsl/glsl_parser.yy +++ b/src/compiler/glsl/glsl_parser.yy @@ -894,6 +894,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 { @@ -905,6 +906,7 @@ parameter_declarator: $$->type->specifier = $1; $$->identifier = $2; $$->array_specifier = $3; + state->symbols->add_variable(new(state) ir_variable(NULL, $2, ir_var_auto)); } ;