Commit d46b31fd by John Kessenich

Give new scopes to non-compound (simple) if-then-else substatements, correcting…

Give new scopes to non-compound (simple) if-then-else substatements, correcting scoping for declarations they contain. Also, updated several tests and the Todo list. git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@22845 e7fa87d3-cd2b-0410-9028-fcbf551c1848
parent 3af0d53d
...@@ -80,6 +80,7 @@ void main() ...@@ -80,6 +80,7 @@ void main()
} }
gl_FragColor.xr; // ERROR, swizzlers not from same field space gl_FragColor.xr; // ERROR, swizzlers not from same field space
gl_FragColor.xyxyx.xy; // ERROR, cannot make a vec5, even temporarily
centTexCoord.z; // ERROR, swizzler out of range centTexCoord.z; // ERROR, swizzler out of range
(a,b) = true; // ERROR, not an l-value (a,b) = true; // ERROR, not an l-value
} }
...@@ -103,4 +104,13 @@ bool gen(vec3 v) ...@@ -103,4 +104,13 @@ bool gen(vec3 v)
{ {
if (abs(v[0]) < 1e-4 && abs(v[1]) < 1e-4) if (abs(v[0]) < 1e-4 && abs(v[1]) < 1e-4)
return true; return true;
} }
\ No newline at end of file
void v1()
{
}
void v2()
{
return v1(); // ERROR, no expression allowed, even though void
}
...@@ -11,3 +11,22 @@ void bar2(highp in float b); ...@@ -11,3 +11,22 @@ void bar2(highp in float b);
smooth flat out vec4 rep; // ERROR, replicating interpolation qualification smooth flat out vec4 rep; // ERROR, replicating interpolation qualification
centroid sample out vec4 rep2; // ERROR, replicating auxiliary qualification centroid sample out vec4 rep2; // ERROR, replicating auxiliary qualification
in uniform vec4 rep3; // ERROR, replicating storage qualification in uniform vec4 rep3; // ERROR, replicating storage qualification
void main()
{
int i;
if (i == 3)
int j = i;
else
int k = j; // ERROR, j is undeclared
int m = k; // ERROR, k is undeclared
int n = j; // ERROR, j is undeclared
while (true)
int jj;
int kk = jj; // ERROR, jj is undeclared
}
void bar(in highp volatile vec4 v)
{
}
\ No newline at end of file
...@@ -15,16 +15,19 @@ ERROR: 0:63: 'assign' : cannot convert from 'bool' to 'float' ...@@ -15,16 +15,19 @@ ERROR: 0:63: 'assign' : cannot convert from 'bool' to 'float'
ERROR: 0:79: ':' : wrong operand types: no operation ':' exists that takes a left-hand operand of type '4-component vector of float' and a right operand of type '4X4 matrix of float' (or there is no acceptable conversion) ERROR: 0:79: ':' : wrong operand types: no operation ':' exists that takes a left-hand operand of type '4-component vector of float' and a right operand of type '4X4 matrix of float' (or there is no acceptable conversion)
ERROR: 0:79: 'assign' : cannot convert from '4X4 matrix of float' to 'fragColor 4-component vector of float' ERROR: 0:79: 'assign' : cannot convert from '4X4 matrix of float' to 'fragColor 4-component vector of float'
ERROR: 0:82: 'xr' : illegal - vector component fields not from the same set ERROR: 0:82: 'xr' : illegal - vector component fields not from the same set
ERROR: 0:83: 'z' : vector field selection out of range ERROR: 0:83: 'xyxyx' : illegal vector field selection
ERROR: 0:84: 'assign' : l-value required ERROR: 0:83: 'xy' : dot operator requires structure, array, vector, or matrix on left hand side
ERROR: 0:90: 'int' : overloaded functions must have the same return type ERROR: 0:84: 'z' : vector field selection out of range
ERROR: 0:90: 'main' : function already has a body ERROR: 0:85: 'assign' : l-value required
ERROR: 0:90: 'int' : main function cannot return a value ERROR: 0:91: 'int' : overloaded functions must have the same return type
ERROR: 0:91: 'main' : function cannot take any parameter(s) ERROR: 0:91: 'main' : function already has a body
ERROR: 0:93: 'a' : variables with qualifier 'const' must be initialized ERROR: 0:91: 'int' : main function cannot return a value
ERROR: 0:96: 'out' : overloaded functions must have the same parameter qualifiers ERROR: 0:92: 'main' : function cannot take any parameter(s)
ERROR: 0:98: 'return' : function return is not matching type: ERROR: 0:94: 'a' : variables with qualifier 'const' must be initialized
ERROR: 26 compilation errors. No code generated. ERROR: 0:97: 'out' : overloaded functions must have the same parameter qualifiers
ERROR: 0:99: 'return' : function return is not matching type:
ERROR: 0:115: 'return' : void function cannot return a value
ERROR: 29 compilation errors. No code generated.
ERROR: node is still EOpNull! ERROR: node is still EOpNull!
0:21 Function Definition: main( (void) 0:21 Function Definition: main( (void)
...@@ -210,48 +213,58 @@ ERROR: node is still EOpNull! ...@@ -210,48 +213,58 @@ ERROR: node is still EOpNull!
0:82 'gl_FragColor' (fragColor 4-component vector of float) 0:82 'gl_FragColor' (fragColor 4-component vector of float)
0:82 0 (const int) 0:82 0 (const int)
0:83 direct index (float) 0:83 direct index (float)
0:83 'centTexCoord' (centroid smooth in 2-component vector of float) 0:83 'gl_FragColor' (fragColor 4-component vector of float)
0:83 0 (const int) 0:83 0 (const int)
0:84 move second child to first child (bool) 0:84 direct index (float)
0:84 Comma (bool) 0:84 'centTexCoord' (centroid smooth in 2-component vector of float)
0:84 'a' (int) 0:84 0 (const int)
0:84 'b' (bool) 0:85 move second child to first child (bool)
0:84 true (const bool) 0:85 Comma (bool)
0:90 Function Definition: main( (int) 0:85 'a' (int)
0:90 Function Parameters: 0:85 'b' (bool)
0:91 Function Definition: main(i1; (void) 0:85 true (const bool)
0:91 Function Definition: main( (int)
0:91 Function Parameters: 0:91 Function Parameters:
0:91 'a' (in int) 0:92 Function Definition: main(i1; (void)
0:96 Function Definition: foo(f1; (int) 0:92 Function Parameters:
0:96 Function Parameters: 0:92 'a' (in int)
0:96 'a' (out float) 0:97 Function Definition: foo(f1; (int)
0:98 Sequence 0:97 Function Parameters:
0:98 Branch: Return with expression 0:97 'a' (out float)
0:98 3.200000 0:99 Sequence
0:99 Function Call: foo(f1; (int) 0:99 Branch: Return with expression
0:99 'a' (out float) 0:99 3.200000
0:102 Function Definition: gen(vf3; (bool) 0:100 Function Call: foo(f1; (int)
0:102 Function Parameters: 0:100 'a' (out float)
0:102 'v' (in 3-component vector of float) 0:103 Function Definition: gen(vf3; (bool)
0:104 Sequence 0:103 Function Parameters:
0:104 Test condition and select (void) 0:103 'v' (in 3-component vector of float)
0:104 Condition 0:105 Sequence
0:104 logical-and (bool) 0:105 Test condition and select (void)
0:104 Compare Less Than (bool) 0:105 Condition
0:104 Absolute value (float) 0:105 logical-and (bool)
0:104 direct index (in float) 0:105 Compare Less Than (bool)
0:104 'v' (in 3-component vector of float) 0:105 Absolute value (float)
0:104 0 (const int) 0:105 direct index (in float)
0:104 0.000100 0:105 'v' (in 3-component vector of float)
0:104 Compare Less Than (bool) 0:105 0 (const int)
0:104 Absolute value (float) 0:105 0.000100
0:104 direct index (in float) 0:105 Compare Less Than (bool)
0:104 'v' (in 3-component vector of float) 0:105 Absolute value (float)
0:104 1 (const int) 0:105 direct index (in float)
0:104 0.000100 0:105 'v' (in 3-component vector of float)
0:104 true case 0:105 1 (const int)
0:105 Branch: Return with expression 0:105 0.000100
0:105 true (const bool) 0:105 true case
0:106 Branch: Return with expression
0:106 true (const bool)
0:109 Function Definition: v1( (void)
0:109 Function Parameters:
0:113 Function Definition: v2( (void)
0:113 Function Parameters:
0:115 Sequence
0:115 Branch: Return with expression
0:115 Function Call: v1( (void)
0:? Linker Objects 0:? Linker Objects
0:? 'i' (smooth in 4-component vector of float) 0:? 'i' (smooth in 4-component vector of float)
0:? 'o' (out 4-component vector of float) 0:? 'o' (out 4-component vector of float)
......
...@@ -75,7 +75,6 @@ numeral.frag ...@@ -75,7 +75,6 @@ numeral.frag
../../LunarGLASS/test/Operations.frag ../../LunarGLASS/test/Operations.frag
../../LunarGLASS/test/prepost.frag ../../LunarGLASS/test/prepost.frag
../../LunarGLASS/test/simpleFunctionCall.frag ../../LunarGLASS/test/simpleFunctionCall.frag
../../LunarGLASS/test/solidworks.frag
../../LunarGLASS/test/structAssignment.frag ../../LunarGLASS/test/structAssignment.frag
../../LunarGLASS/test/structDeref.frag ../../LunarGLASS/test/structDeref.frag
../../LunarGLASS/test/structure.frag ../../LunarGLASS/test/structure.frag
......
...@@ -187,7 +187,7 @@ extern int yylex(YYSTYPE*, TParseContext&); ...@@ -187,7 +187,7 @@ extern int yylex(YYSTYPE*, TParseContext&);
%type <interm.intermNode> declaration external_declaration %type <interm.intermNode> declaration external_declaration
%type <interm.intermNode> for_init_statement compound_statement_no_new_scope %type <interm.intermNode> for_init_statement compound_statement_no_new_scope
%type <interm.nodePair> selection_rest_statement for_rest_statement %type <interm.nodePair> selection_rest_statement for_rest_statement
%type <interm.intermNode> iteration_statement jump_statement statement_no_new_scope %type <interm.intermNode> iteration_statement jump_statement statement_no_new_scope statement_scoped
%type <interm> single_declaration init_declarator_list %type <interm> single_declaration init_declarator_list
%type <interm> parameter_declaration parameter_declarator parameter_type_specifier %type <interm> parameter_declaration parameter_declarator parameter_type_specifier
...@@ -2599,6 +2599,10 @@ statement_no_new_scope ...@@ -2599,6 +2599,10 @@ statement_no_new_scope
| simple_statement { $$ = $1; } | simple_statement { $$ = $1; }
; ;
statement_scoped
: compound_statement { $$ = $1; }
| { parseContext.symbolTable.push(); } simple_statement { parseContext.symbolTable.pop(&parseContext.defaultPrecision[0]); } { $$ = $2; }
compound_statement_no_new_scope compound_statement_no_new_scope
// Statement that doesn't create a new scope, for selection_statement, iteration_statement // Statement that doesn't create a new scope, for selection_statement, iteration_statement
: LEFT_BRACE RIGHT_BRACE { : LEFT_BRACE RIGHT_BRACE {
...@@ -2643,11 +2647,11 @@ selection_statement ...@@ -2643,11 +2647,11 @@ selection_statement
; ;
selection_rest_statement selection_rest_statement
: statement ELSE statement { : statement_scoped ELSE statement_scoped {
$$.node1 = $1; $$.node1 = $1;
$$.node2 = $3; $$.node2 = $3;
} }
| statement { | statement_scoped {
$$.node1 = $1; $$.node1 = $1;
$$.node2 = 0; $$.node2 = 0;
} }
......
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