Commit 0637eac3 by Nicolas Capens

Fix local variable hides function parameter for GLSL ES 1.0

GLSL ES 1.0 specifies that "a function body has a scope nested inside the function’s definition". For GLSL ES 3.0, they form a single scope. Both specs use the compound_statement_no_new_scope rule. This change respects that while supporting both behaviors. It does not impact legacy content since it makes things more permissive. Change-Id: Ica40fbf4d24d441ca2288fe5d43c288161e16b89 Reviewed-on: https://swiftshader-review.googlesource.com/5055Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 85c4f9e0
...@@ -1591,9 +1591,11 @@ external_declaration ...@@ -1591,9 +1591,11 @@ external_declaration
function_definition function_definition
: function_prototype { : function_prototype {
context->parseFunctionPrototype(@1, $1.function, &$1.intermAggregate); context->parseFunctionPrototype(@1, $1.function, &$1.intermAggregate);
if (context->getShaderVersion() == 100) context->symbolTable.push();
} }
compound_statement_no_new_scope { compound_statement_no_new_scope {
$$ = context->addFunctionDefinition(*($1.function), $1.intermAggregate, $3, @1); $$ = context->addFunctionDefinition(*($1.function), $1.intermAggregate, $3, @1);
if (context->getShaderVersion() == 100) context->symbolTable.pop();
} }
; ;
......
...@@ -4831,6 +4831,7 @@ yyreduce: ...@@ -4831,6 +4831,7 @@ yyreduce:
{ {
context->parseFunctionPrototype((yylsp[0]), (yyvsp[0].interm).function, &(yyvsp[0].interm).intermAggregate); context->parseFunctionPrototype((yylsp[0]), (yyvsp[0].interm).function, &(yyvsp[0].interm).intermAggregate);
if (context->getShaderVersion() == 100) context->symbolTable.push();
} }
break; break;
...@@ -4839,6 +4840,7 @@ yyreduce: ...@@ -4839,6 +4840,7 @@ yyreduce:
{ {
(yyval.interm.intermNode) = context->addFunctionDefinition(*((yyvsp[-2].interm).function), (yyvsp[-2].interm).intermAggregate, (yyvsp[0].interm.intermAggregate), (yylsp[-2])); (yyval.interm.intermNode) = context->addFunctionDefinition(*((yyvsp[-2].interm).function), (yyvsp[-2].interm).intermAggregate, (yyvsp[0].interm.intermAggregate), (yylsp[-2]));
if (context->getShaderVersion() == 100) context->symbolTable.pop();
} }
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment