From 0637eac3b8fd276596b303aaa7e5d59a3accccf8 Mon Sep 17 00:00:00 2001 From: Nicolas Capens Date: Thu, 7 Apr 2016 15:12:39 -0400 Subject: [PATCH] Fix local variable hides function parameter for GLSL ES 1.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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/5055 Tested-by: Nicolas Capens Reviewed-by: Alexis Hétu Reviewed-by: Nicolas Capens --- src/OpenGL/compiler/glslang.y | 2 ++ src/OpenGL/compiler/glslang_tab.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/OpenGL/compiler/glslang.y b/src/OpenGL/compiler/glslang.y index 3030144b7..1ecf46858 100644 --- a/src/OpenGL/compiler/glslang.y +++ b/src/OpenGL/compiler/glslang.y @@ -1591,9 +1591,11 @@ external_declaration function_definition : function_prototype { context->parseFunctionPrototype(@1, $1.function, &$1.intermAggregate); + if (context->getShaderVersion() == 100) context->symbolTable.push(); } compound_statement_no_new_scope { $$ = context->addFunctionDefinition(*($1.function), $1.intermAggregate, $3, @1); + if (context->getShaderVersion() == 100) context->symbolTable.pop(); } ; diff --git a/src/OpenGL/compiler/glslang_tab.cpp b/src/OpenGL/compiler/glslang_tab.cpp index 2e23afea3..ad7bd4d7f 100644 --- a/src/OpenGL/compiler/glslang_tab.cpp +++ b/src/OpenGL/compiler/glslang_tab.cpp @@ -4831,6 +4831,7 @@ yyreduce: { context->parseFunctionPrototype((yylsp[0]), (yyvsp[0].interm).function, &(yyvsp[0].interm).intermAggregate); + if (context->getShaderVersion() == 100) context->symbolTable.push(); } break; @@ -4839,6 +4840,7 @@ yyreduce: { (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; -- 2.11.0