Fix scope definition in ES 100. (#2379)

* Remove image2DShadow and other 3 tokens. Refine codes.

Remove image2DShadow and other 3 tokens. Refine codes.

* 110scope.vert has redefinition part of what's removed from 100scope.vert
This commit is contained in:
Chow 2020-09-14 22:00:48 +08:00 committed by GitHub
parent f8a5602c55
commit 3933d7d414
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 91 additions and 26 deletions

View File

@ -2,7 +2,7 @@
int f(int a, int b, int c) int f(int a, int b, int c)
{ {
int a = b; // ERROR, redefinition int a = b;
{ {
float a = float(a) + 1.0; float a = float(a) + 1.0;

View File

@ -1,5 +1,4 @@
100scope.vert 100scope.vert
ERROR: 0:5: 'a' : redefinition
ERROR: 0:17: 'b' : function name is redeclaration of existing name ERROR: 0:17: 'b' : function name is redeclaration of existing name
ERROR: 0:20: 'c' : redefinition ERROR: 0:20: 'c' : redefinition
ERROR: 0:22: 'f' : redefinition ERROR: 0:22: 'f' : redefinition
@ -13,7 +12,7 @@ ERROR: 0:57: 'z' : undeclared identifier
ERROR: 0:57: 'z' : redefinition ERROR: 0:57: 'z' : redefinition
ERROR: 0:73: 'degrees' : can't use function syntax on variable ERROR: 0:73: 'degrees' : can't use function syntax on variable
ERROR: 0:76: 'vertex-shader struct output' : not supported for this version or the enabled extensions ERROR: 0:76: 'vertex-shader struct output' : not supported for this version or the enabled extensions
ERROR: 14 compilation errors. No code generated. ERROR: 13 compilation errors. No code generated.
Shader version: 100 Shader version: 100
@ -23,18 +22,22 @@ ERROR: node is still EOpNull!
0:3 'a' ( in highp int) 0:3 'a' ( in highp int)
0:3 'b' ( in highp int) 0:3 'b' ( in highp int)
0:3 'c' ( in highp int) 0:3 'c' ( in highp int)
0:? Sequence 0:5 Sequence
0:5 Sequence
0:5 move second child to first child ( temp highp int)
0:5 'a' ( temp highp int)
0:5 'b' ( in highp int)
0:8 Sequence 0:8 Sequence
0:8 Sequence 0:8 Sequence
0:8 move second child to first child ( temp highp float) 0:8 move second child to first child ( temp highp float)
0:8 'a' ( temp highp float) 0:8 'a' ( temp highp float)
0:8 add ( temp highp float) 0:8 add ( temp highp float)
0:8 Convert int to float ( temp highp float) 0:8 Convert int to float ( temp highp float)
0:8 'a' ( in highp int) 0:8 'a' ( temp highp int)
0:8 Constant: 0:8 Constant:
0:8 1.000000 0:8 1.000000
0:11 Branch: Return with expression 0:11 Branch: Return with expression
0:11 'a' ( in highp int) 0:11 'a' ( temp highp int)
0:25 Function Definition: cos(f1; ( global highp float) 0:25 Function Definition: cos(f1; ( global highp float)
0:25 Function Parameters: 0:25 Function Parameters:
0:25 'x' ( in highp float) 0:25 'x' ( in highp float)
@ -138,18 +141,22 @@ ERROR: node is still EOpNull!
0:3 'a' ( in highp int) 0:3 'a' ( in highp int)
0:3 'b' ( in highp int) 0:3 'b' ( in highp int)
0:3 'c' ( in highp int) 0:3 'c' ( in highp int)
0:? Sequence 0:5 Sequence
0:5 Sequence
0:5 move second child to first child ( temp highp int)
0:5 'a' ( temp highp int)
0:5 'b' ( in highp int)
0:8 Sequence 0:8 Sequence
0:8 Sequence 0:8 Sequence
0:8 move second child to first child ( temp highp float) 0:8 move second child to first child ( temp highp float)
0:8 'a' ( temp highp float) 0:8 'a' ( temp highp float)
0:8 add ( temp highp float) 0:8 add ( temp highp float)
0:8 Convert int to float ( temp highp float) 0:8 Convert int to float ( temp highp float)
0:8 'a' ( in highp int) 0:8 'a' ( temp highp int)
0:8 Constant: 0:8 Constant:
0:8 1.000000 0:8 1.000000
0:11 Branch: Return with expression 0:11 Branch: Return with expression
0:11 'a' ( in highp int) 0:11 'a' ( temp highp int)
0:36 Function Definition: main( ( global void) 0:36 Function Definition: main( ( global void)
0:36 Function Parameters: 0:36 Function Parameters:
0:? Sequence 0:? Sequence

View File

@ -84,6 +84,7 @@ public:
scopeMangler("::"), scopeMangler("::"),
symbolTable(symbolTable), symbolTable(symbolTable),
statementNestingLevel(0), loopNestingLevel(0), structNestingLevel(0), controlFlowNestingLevel(0), statementNestingLevel(0), loopNestingLevel(0), structNestingLevel(0), controlFlowNestingLevel(0),
currentFunctionType(nullptr),
postEntryPointReturn(false), postEntryPointReturn(false),
contextPragma(true, false), contextPragma(true, false),
beginInvocationInterlockCount(0), endInvocationInterlockCount(0), beginInvocationInterlockCount(0), endInvocationInterlockCount(0),

View File

@ -3842,6 +3842,14 @@ function_definition
: function_prototype { : function_prototype {
$1.function = parseContext.handleFunctionDeclarator($1.loc, *$1.function, false /* not prototype */); $1.function = parseContext.handleFunctionDeclarator($1.loc, *$1.function, false /* not prototype */);
$1.intermNode = parseContext.handleFunctionDefinition($1.loc, *$1.function); $1.intermNode = parseContext.handleFunctionDefinition($1.loc, *$1.function);
// For ES 100 only, according to ES shading language 100 spec: A function
// body has a scope nested inside the function's definition.
if (parseContext.profile == EEsProfile && parseContext.version == 100)
{
parseContext.symbolTable.push();
++parseContext.statementNestingLevel;
}
} }
compound_statement_no_new_scope { compound_statement_no_new_scope {
// May be best done as post process phase on intermediate code // May be best done as post process phase on intermediate code
@ -3857,6 +3865,17 @@ function_definition
$$->getAsAggregate()->setOptimize(parseContext.contextPragma.optimize); $$->getAsAggregate()->setOptimize(parseContext.contextPragma.optimize);
$$->getAsAggregate()->setDebug(parseContext.contextPragma.debug); $$->getAsAggregate()->setDebug(parseContext.contextPragma.debug);
$$->getAsAggregate()->setPragmaTable(parseContext.contextPragma.pragmaTable); $$->getAsAggregate()->setPragmaTable(parseContext.contextPragma.pragmaTable);
// Set currentFunctionType to empty pointer when goes outside of the function
parseContext.currentFunctionType = nullptr;
// For ES 100 only, according to ES shading language 100 spec: A function
// body has a scope nested inside the function's definition.
if (parseContext.profile == EEsProfile && parseContext.version == 100)
{
parseContext.symbolTable.pop(&parseContext.defaultPrecision[0]);
--parseContext.statementNestingLevel;
}
} }
; ;

View File

@ -3842,6 +3842,14 @@ function_definition
: function_prototype { : function_prototype {
$1.function = parseContext.handleFunctionDeclarator($1.loc, *$1.function, false /* not prototype */); $1.function = parseContext.handleFunctionDeclarator($1.loc, *$1.function, false /* not prototype */);
$1.intermNode = parseContext.handleFunctionDefinition($1.loc, *$1.function); $1.intermNode = parseContext.handleFunctionDefinition($1.loc, *$1.function);
// For ES 100 only, according to ES shading language 100 spec: A function
// body has a scope nested inside the function's definition.
if (parseContext.profile == EEsProfile && parseContext.version == 100)
{
parseContext.symbolTable.push();
++parseContext.statementNestingLevel;
}
} }
compound_statement_no_new_scope { compound_statement_no_new_scope {
// May be best done as post process phase on intermediate code // May be best done as post process phase on intermediate code
@ -3857,6 +3865,17 @@ function_definition
$$->getAsAggregate()->setOptimize(parseContext.contextPragma.optimize); $$->getAsAggregate()->setOptimize(parseContext.contextPragma.optimize);
$$->getAsAggregate()->setDebug(parseContext.contextPragma.debug); $$->getAsAggregate()->setDebug(parseContext.contextPragma.debug);
$$->getAsAggregate()->setPragmaTable(parseContext.contextPragma.pragmaTable); $$->getAsAggregate()->setPragmaTable(parseContext.contextPragma.pragmaTable);
// Set currentFunctionType to empty pointer when goes outside of the function
parseContext.currentFunctionType = nullptr;
// For ES 100 only, according to ES shading language 100 spec: A function
// body has a scope nested inside the function's definition.
if (parseContext.profile == EEsProfile && parseContext.version == 100)
{
parseContext.symbolTable.pop(&parseContext.defaultPrecision[0]);
--parseContext.statementNestingLevel;
}
} }
; ;

View File

@ -1012,8 +1012,8 @@ static const yytype_uint16 yyrline[] =
3603, 3611, 3615, 3628, 3632, 3639, 3639, 3659, 3662, 3668, 3603, 3611, 3615, 3628, 3632, 3639, 3639, 3659, 3662, 3668,
3680, 3692, 3696, 3703, 3703, 3718, 3718, 3734, 3734, 3755, 3680, 3692, 3696, 3703, 3703, 3718, 3718, 3734, 3734, 3755,
3758, 3764, 3767, 3773, 3777, 3784, 3789, 3794, 3801, 3804, 3758, 3764, 3767, 3773, 3777, 3784, 3789, 3794, 3801, 3804,
3813, 3817, 3826, 3829, 3833, 3842, 3842, 3865, 3871, 3874, 3813, 3817, 3826, 3829, 3833, 3842, 3842, 3884, 3890, 3893,
3879, 3882 3898, 3901
}; };
#endif #endif
@ -10298,12 +10298,20 @@ yyreduce:
{ {
(yyvsp[0].interm).function = parseContext.handleFunctionDeclarator((yyvsp[0].interm).loc, *(yyvsp[0].interm).function, false /* not prototype */); (yyvsp[0].interm).function = parseContext.handleFunctionDeclarator((yyvsp[0].interm).loc, *(yyvsp[0].interm).function, false /* not prototype */);
(yyvsp[0].interm).intermNode = parseContext.handleFunctionDefinition((yyvsp[0].interm).loc, *(yyvsp[0].interm).function); (yyvsp[0].interm).intermNode = parseContext.handleFunctionDefinition((yyvsp[0].interm).loc, *(yyvsp[0].interm).function);
// For ES 100 only, according to ES shading language 100 spec: A function
// body has a scope nested inside the function's definition.
if (parseContext.profile == EEsProfile && parseContext.version == 100)
{
parseContext.symbolTable.push();
++parseContext.statementNestingLevel;
}
} }
#line 10303 "MachineIndependent/glslang_tab.cpp" /* yacc.c:1646 */ #line 10311 "MachineIndependent/glslang_tab.cpp" /* yacc.c:1646 */
break; break;
case 586: case 586:
#line 3846 "MachineIndependent/glslang.y" /* yacc.c:1646 */ #line 3854 "MachineIndependent/glslang.y" /* yacc.c:1646 */
{ {
// May be best done as post process phase on intermediate code // May be best done as post process phase on intermediate code
if (parseContext.currentFunctionType->getBasicType() != EbtVoid && ! parseContext.functionReturnsValue) if (parseContext.currentFunctionType->getBasicType() != EbtVoid && ! parseContext.functionReturnsValue)
@ -10318,53 +10326,64 @@ yyreduce:
(yyval.interm.intermNode)->getAsAggregate()->setOptimize(parseContext.contextPragma.optimize); (yyval.interm.intermNode)->getAsAggregate()->setOptimize(parseContext.contextPragma.optimize);
(yyval.interm.intermNode)->getAsAggregate()->setDebug(parseContext.contextPragma.debug); (yyval.interm.intermNode)->getAsAggregate()->setDebug(parseContext.contextPragma.debug);
(yyval.interm.intermNode)->getAsAggregate()->setPragmaTable(parseContext.contextPragma.pragmaTable); (yyval.interm.intermNode)->getAsAggregate()->setPragmaTable(parseContext.contextPragma.pragmaTable);
// Set currentFunctionType to empty pointer when goes outside of the function
parseContext.currentFunctionType = nullptr;
// For ES 100 only, according to ES shading language 100 spec: A function
// body has a scope nested inside the function's definition.
if (parseContext.profile == EEsProfile && parseContext.version == 100)
{
parseContext.symbolTable.pop(&parseContext.defaultPrecision[0]);
--parseContext.statementNestingLevel;
}
} }
#line 10323 "MachineIndependent/glslang_tab.cpp" /* yacc.c:1646 */ #line 10342 "MachineIndependent/glslang_tab.cpp" /* yacc.c:1646 */
break; break;
case 587: case 587:
#line 3865 "MachineIndependent/glslang.y" /* yacc.c:1646 */ #line 3884 "MachineIndependent/glslang.y" /* yacc.c:1646 */
{ {
(yyval.interm.attributes) = (yyvsp[-2].interm.attributes); (yyval.interm.attributes) = (yyvsp[-2].interm.attributes);
parseContext.requireExtensions((yyvsp[-4].lex).loc, 1, &E_GL_EXT_control_flow_attributes, "attribute"); parseContext.requireExtensions((yyvsp[-4].lex).loc, 1, &E_GL_EXT_control_flow_attributes, "attribute");
} }
#line 10332 "MachineIndependent/glslang_tab.cpp" /* yacc.c:1646 */ #line 10351 "MachineIndependent/glslang_tab.cpp" /* yacc.c:1646 */
break; break;
case 588: case 588:
#line 3871 "MachineIndependent/glslang.y" /* yacc.c:1646 */ #line 3890 "MachineIndependent/glslang.y" /* yacc.c:1646 */
{ {
(yyval.interm.attributes) = (yyvsp[0].interm.attributes); (yyval.interm.attributes) = (yyvsp[0].interm.attributes);
} }
#line 10340 "MachineIndependent/glslang_tab.cpp" /* yacc.c:1646 */ #line 10359 "MachineIndependent/glslang_tab.cpp" /* yacc.c:1646 */
break; break;
case 589: case 589:
#line 3874 "MachineIndependent/glslang.y" /* yacc.c:1646 */ #line 3893 "MachineIndependent/glslang.y" /* yacc.c:1646 */
{ {
(yyval.interm.attributes) = parseContext.mergeAttributes((yyvsp[-2].interm.attributes), (yyvsp[0].interm.attributes)); (yyval.interm.attributes) = parseContext.mergeAttributes((yyvsp[-2].interm.attributes), (yyvsp[0].interm.attributes));
} }
#line 10348 "MachineIndependent/glslang_tab.cpp" /* yacc.c:1646 */ #line 10367 "MachineIndependent/glslang_tab.cpp" /* yacc.c:1646 */
break; break;
case 590: case 590:
#line 3879 "MachineIndependent/glslang.y" /* yacc.c:1646 */ #line 3898 "MachineIndependent/glslang.y" /* yacc.c:1646 */
{ {
(yyval.interm.attributes) = parseContext.makeAttributes(*(yyvsp[0].lex).string); (yyval.interm.attributes) = parseContext.makeAttributes(*(yyvsp[0].lex).string);
} }
#line 10356 "MachineIndependent/glslang_tab.cpp" /* yacc.c:1646 */ #line 10375 "MachineIndependent/glslang_tab.cpp" /* yacc.c:1646 */
break; break;
case 591: case 591:
#line 3882 "MachineIndependent/glslang.y" /* yacc.c:1646 */ #line 3901 "MachineIndependent/glslang.y" /* yacc.c:1646 */
{ {
(yyval.interm.attributes) = parseContext.makeAttributes(*(yyvsp[-3].lex).string, (yyvsp[-1].interm.intermTypedNode)); (yyval.interm.attributes) = parseContext.makeAttributes(*(yyvsp[-3].lex).string, (yyvsp[-1].interm.intermTypedNode));
} }
#line 10364 "MachineIndependent/glslang_tab.cpp" /* yacc.c:1646 */ #line 10383 "MachineIndependent/glslang_tab.cpp" /* yacc.c:1646 */
break; break;
#line 10368 "MachineIndependent/glslang_tab.cpp" /* yacc.c:1646 */ #line 10387 "MachineIndependent/glslang_tab.cpp" /* yacc.c:1646 */
default: break; default: break;
} }
/* User semantic actions sometimes alter yychar, and that requires /* User semantic actions sometimes alter yychar, and that requires
@ -10592,5 +10611,5 @@ yyreturn:
#endif #endif
return yyresult; return yyresult;
} }
#line 3887 "MachineIndependent/glslang.y" /* yacc.c:1906 */ #line 3906 "MachineIndependent/glslang.y" /* yacc.c:1906 */