diff --git a/Install/Windows/glslangValidator.exe b/Install/Windows/glslangValidator.exe index 9e288e73157a9b7c3e54dc5b2edb067bddca97e6..0c00fc8880560db05d04770d937c9ceeeff017c2 100644 Binary files a/Install/Windows/glslangValidator.exe and b/Install/Windows/glslangValidator.exe differ diff --git a/Test/100scope.vert b/Test/100scope.vert index f7e2675673750a8977ea8d6d93b98490d669cdd4..b0a72d1f191d80c3f357b4bcce08e8d23fa60e40 100644 --- a/Test/100scope.vert +++ b/Test/100scope.vert @@ -16,6 +16,9 @@ int f(int a, int b, int c); // okay to redeclare bool b; float b(int a); // ERROR: redefinition +float c(int a); +bool c; // ERROR: redefinition + float f; // ERROR: redefinition float tan; // okay, built-in is in an outer scope float sin(float x); // ERROR: can't redefine built-in functions @@ -37,7 +40,7 @@ void main() float sin; // okay sin; - + sin(0.7); // ERROR, use of hidden function f(1,2,3); float f; // hides f() @@ -65,6 +68,9 @@ void main() S S = S(0); // 'S' is only visible as a struct and constructor S.x; // 'S' is now visible as a variable } + + int degrees; + degrees(3.2); // ERROR, use of hidden built-in function } varying struct SSS { float f; } s; // ERROR diff --git a/Test/110scope.vert b/Test/110scope.vert new file mode 100644 index 0000000000000000000000000000000000000000..564059a2c42e91961aa474bddc636b67166aaa9f --- /dev/null +++ b/Test/110scope.vert @@ -0,0 +1,74 @@ +#version 110 + +int f(int a, int b, int c) +{ + int a = b; // ERROR, redefinition + + { + float a = float(a) + 1.0; // okay + } + + return a; +} + +int f(int a, int b, int c); // okay to redeclare + +bool b; +float b(int a); // okay, b and b() are different + +float c(int a); +bool c; // okay, and c() are different + +float f; // okay f and f() are different +float tan; // okay, hides built-in function +float sin(float x); // okay, can redefine built-in functions +float cos(float x) // okay, can redefine built-in functions +{ + return 1.0; +} +bool radians(bool x) // okay, can overload built-in functions +{ + return true; +} + + + +void main() +{ + int g(); // okay + g(); + + float sin; // okay + sin; + sin(0.7); // okay + f(1,2,3); + + float f; + f = 3.0; + + gl_Position = vec4(f); + + for (int f = 0; f < 10; ++f) + ++f; + + int x = 1; + { + float x = 2.0, /* 2nd x visible here */ y = x; // y is initialized to 2 + int z = z; // ERROR: z not previously defined. + } + { + int x = x; // x is initialized to '1' + } + + struct S + { + int x; + }; + { + S S = S(0); // 'S' is only visible as a struct and constructor + S.x; // 'S' is now visible as a variable + } + + int degrees; + degrees(3.2); +} diff --git a/Test/300scope.vert b/Test/300scope.vert index f88cb0581b310831aae9e6ba99fbc0375125b145..162e99822c864dfb9169ddbaccf0dd376718d243 100644 --- a/Test/300scope.vert +++ b/Test/300scope.vert @@ -16,6 +16,9 @@ int f(int a, int b, int c); // okay to redeclare bool b; float b(int a); // ERROR: redefinition +float c(int a); +bool c; // ERROR: redefinition + float f; // ERROR: redefinition float tan; // ERROR: redefines built-in function float sin(float x); // ERROR: can't redefine built-in functions @@ -37,7 +40,7 @@ void main() float sin; // okay sin; - + sin(0.7); // ERROR, use of hidden function f(1,2,3); float f; // hides f() @@ -65,4 +68,7 @@ void main() S S = S(0); // 'S' is only visible as a struct and constructor S.x; // 'S' is now visible as a variable } + + int degrees; + degrees(3.2); // ERROR, use of hidden built-in function } diff --git a/Test/430scope.vert b/Test/430scope.vert index b854ef74d04b97d6cbb9c879629d42c8c86aaff8..7efa1623d607fee397f5f51c23ae50481d0feca4 100644 --- a/Test/430scope.vert +++ b/Test/430scope.vert @@ -16,6 +16,9 @@ int f(int a, int b, int c); // okay to redeclare bool b; float b(int a); // ERROR: redefinition +float c(int a); +bool c; // ERROR: redefinition + float f; // ERROR: redefinition float tan; // okay, hides built-in function float sin(float x); // okay, can redefine built-in functions @@ -37,7 +40,7 @@ void main() float sin; // okay sin; - + sin(0.7); // ERROR, use of hidden function f(1,2,3); float f; // hides f() @@ -65,4 +68,7 @@ void main() S S = S(0); // 'S' is only visible as a struct and constructor S.x; // 'S' is now visible as a variable } + + int degrees; + degrees(3.2); // ERROR, use of hidden built-in function } diff --git a/Test/baseResults/100scope.vert.out b/Test/baseResults/100scope.vert.out index f155096c79198e07692d929113b73f3a0d4d46f2..a196adef94da76588e11232ae94796efa8387147 100644 --- a/Test/baseResults/100scope.vert.out +++ b/Test/baseResults/100scope.vert.out @@ -1,14 +1,17 @@ 100scope.vert ERROR: 0:5: 'a' : redefinition ERROR: 0:17: 'b' : function name is redeclaration of existing name -ERROR: 0:19: 'f' : redefinition -ERROR: 0:21: 'redefinition of built-in function' : not supported with this profile: es -ERROR: 0:22: 'redefinition of built-in function' : not supported with this profile: es -ERROR: 0:35: 'local function declaration' : not supported with this profile: es -ERROR: 0:54: 'z' : undeclared identifier -ERROR: 0:54: 'z' : redefinition -ERROR: 0:70: 'vertex-shader struct output' : not supported for this version or the enabled extensions -ERROR: 9 compilation errors. No code generated. +ERROR: 0:20: 'c' : redefinition +ERROR: 0:22: 'f' : redefinition +ERROR: 0:24: 'redefinition of built-in function' : not supported with this profile: es +ERROR: 0:25: 'redefinition of built-in function' : not supported with this profile: es +ERROR: 0:38: 'local function declaration' : not supported with this profile: es +ERROR: 0:43: 'sin' : can't use function syntax on variable +ERROR: 0:57: 'z' : undeclared identifier +ERROR: 0:57: 'z' : redefinition +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: 12 compilation errors. No code generated. ERROR: node is still EOpNull! @@ -29,87 +32,91 @@ ERROR: node is still EOpNull! 0:8 1.000000 0:11 Branch: Return with expression 0:11 'a' (in highp int) -0:22 Function Definition: cos(f1; (highp float) -0:22 Function Parameters: -0:22 'x' (in highp float) -0:24 Sequence -0:24 Branch: Return with expression -0:24 Constant: -0:24 1.000000 -0:26 Function Definition: radians(b1; (bool) -0:26 Function Parameters: -0:26 'x' (in bool) -0:28 Sequence -0:28 Branch: Return with expression -0:28 Constant: -0:28 true (const bool) -0:33 Function Definition: main( (void) -0:33 Function Parameters: +0:25 Function Definition: cos(f1; (highp float) +0:25 Function Parameters: +0:25 'x' (in highp float) +0:27 Sequence +0:27 Branch: Return with expression +0:27 Constant: +0:27 1.000000 +0:29 Function Definition: radians(b1; (bool) +0:29 Function Parameters: +0:29 'x' (in bool) +0:31 Sequence +0:31 Branch: Return with expression +0:31 Constant: +0:31 true (const bool) +0:36 Function Definition: main( (void) +0:36 Function Parameters: 0:? Sequence -0:36 Function Call: g( (highp int) -0:39 'sin' (highp float) -0:41 Function Call: f(i1;i1;i1; (highp int) -0:41 Constant: -0:41 1 (const int) -0:41 Constant: -0:41 2 (const int) -0:41 Constant: -0:41 3 (const int) -0:44 move second child to first child (highp float) -0:44 'f' (highp float) +0:39 Function Call: g( (highp int) +0:42 'sin' (highp float) +0:43 Constant: +0:43 0.000000 +0:44 Function Call: f(i1;i1;i1; (highp int) 0:44 Constant: -0:44 3.000000 -0:46 move second child to first child (highp 4-component vector of float) -0:46 'gl_Position' (invariant gl_Position highp 4-component vector of float) -0:46 Construct vec4 (highp 4-component vector of float) -0:46 'f' (highp float) -0:48 Sequence -0:48 Sequence -0:48 move second child to first child (highp int) -0:48 'f' (highp int) -0:48 Constant: -0:48 0 (const int) -0:48 Loop with condition tested first -0:48 Loop Condition -0:48 Compare Less Than (bool) -0:48 'f' (highp int) -0:48 Constant: -0:48 10 (const int) -0:48 Loop Body -0:49 Pre-Increment (highp int) -0:49 'f' (highp int) -0:48 Loop Terminal Expression -0:48 Pre-Increment (highp int) -0:48 'f' (highp int) +0:44 1 (const int) +0:44 Constant: +0:44 2 (const int) +0:44 Constant: +0:44 3 (const int) +0:47 move second child to first child (highp float) +0:47 'f' (highp float) +0:47 Constant: +0:47 3.000000 +0:49 move second child to first child (highp 4-component vector of float) +0:49 'gl_Position' (invariant gl_Position highp 4-component vector of float) +0:49 Construct vec4 (highp 4-component vector of float) +0:49 'f' (highp float) 0:51 Sequence -0:51 move second child to first child (highp int) -0:51 'x' (highp int) -0:51 Constant: -0:51 1 (const int) -0:53 Sequence -0:53 Sequence -0:53 move second child to first child (highp float) -0:53 'x' (highp float) -0:53 Constant: -0:53 2.000000 -0:53 move second child to first child (highp float) -0:53 'y' (highp float) -0:53 'x' (highp float) -0:57 Sequence -0:57 Sequence -0:57 move second child to first child (highp int) -0:57 'x' (highp int) -0:57 'x' (highp int) -0:65 Sequence -0:65 Sequence -0:65 move second child to first child (structure{x}) -0:65 'S' (structure{x}) -0:65 Constant: -0:65 0 (const int) -0:66 x: direct index for structure (highp int) -0:66 'S' (structure{x}) -0:66 Constant: -0:66 0 (const int) +0:51 Sequence +0:51 move second child to first child (highp int) +0:51 'f' (highp int) +0:51 Constant: +0:51 0 (const int) +0:51 Loop with condition tested first +0:51 Loop Condition +0:51 Compare Less Than (bool) +0:51 'f' (highp int) +0:51 Constant: +0:51 10 (const int) +0:51 Loop Body +0:52 Pre-Increment (highp int) +0:52 'f' (highp int) +0:51 Loop Terminal Expression +0:51 Pre-Increment (highp int) +0:51 'f' (highp int) +0:54 Sequence +0:54 move second child to first child (highp int) +0:54 'x' (highp int) +0:54 Constant: +0:54 1 (const int) +0:56 Sequence +0:56 Sequence +0:56 move second child to first child (highp float) +0:56 'x' (highp float) +0:56 Constant: +0:56 2.000000 +0:56 move second child to first child (highp float) +0:56 'y' (highp float) +0:56 'x' (highp float) +0:60 Sequence +0:60 Sequence +0:60 move second child to first child (highp int) +0:60 'x' (highp int) +0:60 'x' (highp int) +0:68 Sequence +0:68 Sequence +0:68 move second child to first child (structure{x}) +0:68 'S' (structure{x}) +0:68 Constant: +0:68 0 (const int) +0:69 x: direct index for structure (highp int) +0:69 'S' (structure{x}) +0:69 Constant: +0:69 0 (const int) +0:73 Constant: +0:73 0.000000 0:? Linker Objects 0:? 'b' (bool) 0:? 'tan' (highp float) diff --git a/Test/baseResults/110scope.vert.out b/Test/baseResults/110scope.vert.out new file mode 100644 index 0000000000000000000000000000000000000000..cabb6582fced74c0072a0d7e1082eb629debea88 --- /dev/null +++ b/Test/baseResults/110scope.vert.out @@ -0,0 +1,122 @@ +110scope.vert +ERROR: 0:5: 'a' : redefinition +ERROR: 0:57: 'z' : undeclared identifier +ERROR: 0:57: 'z' : redefinition +ERROR: 3 compilation errors. No code generated. + + +ERROR: node is still EOpNull! +0:3 Function Definition: f(i1;i1;i1; (int) +0:3 Function Parameters: +0:3 'a' (in int) +0:3 'b' (in int) +0:3 'c' (in int) +0:? Sequence +0:8 Sequence +0:8 Sequence +0:8 move second child to first child (float) +0:8 'a' (float) +0:8 add (float) +0:8 Convert int to float (float) +0:8 'a' (in int) +0:8 Constant: +0:8 1.000000 +0:11 Branch: Return with expression +0:11 'a' (in int) +0:25 Function Definition: cos(f1; (float) +0:25 Function Parameters: +0:25 'x' (in float) +0:27 Sequence +0:27 Branch: Return with expression +0:27 Constant: +0:27 1.000000 +0:29 Function Definition: radians(b1; (bool) +0:29 Function Parameters: +0:29 'x' (in bool) +0:31 Sequence +0:31 Branch: Return with expression +0:31 Constant: +0:31 true (const bool) +0:36 Function Definition: main( (void) +0:36 Function Parameters: +0:? Sequence +0:39 Function Call: g( (int) +0:42 'sin' (float) +0:43 Function Call: sin(f1; (float) +0:43 Constant: +0:43 0.700000 +0:44 Function Call: f(i1;i1;i1; (int) +0:44 Constant: +0:44 1 (const int) +0:44 Constant: +0:44 2 (const int) +0:44 Constant: +0:44 3 (const int) +0:47 move second child to first child (float) +0:47 'f' (float) +0:47 Constant: +0:47 3.000000 +0:49 move second child to first child (4-component vector of float) +0:49 'gl_Position' (gl_Position 4-component vector of float) +0:49 Construct vec4 (4-component vector of float) +0:49 'f' (float) +0:51 Sequence +0:51 Sequence +0:51 move second child to first child (int) +0:51 'f' (int) +0:51 Constant: +0:51 0 (const int) +0:51 Loop with condition tested first +0:51 Loop Condition +0:51 Compare Less Than (bool) +0:51 'f' (int) +0:51 Constant: +0:51 10 (const int) +0:51 Loop Body +0:52 Pre-Increment (int) +0:52 'f' (int) +0:51 Loop Terminal Expression +0:51 Pre-Increment (int) +0:51 'f' (int) +0:54 Sequence +0:54 move second child to first child (int) +0:54 'x' (int) +0:54 Constant: +0:54 1 (const int) +0:56 Sequence +0:56 Sequence +0:56 move second child to first child (float) +0:56 'x' (float) +0:56 Constant: +0:56 2.000000 +0:56 move second child to first child (float) +0:56 'y' (float) +0:56 'x' (float) +0:60 Sequence +0:60 Sequence +0:60 move second child to first child (int) +0:60 'x' (int) +0:60 'x' (int) +0:68 Sequence +0:68 Sequence +0:68 move second child to first child (structure{x}) +0:68 'S' (structure{x}) +0:68 Constant: +0:68 0 (const int) +0:69 x: direct index for structure (int) +0:69 'S' (structure{x}) +0:69 Constant: +0:69 0 (const int) +0:73 Constant: +0:73 183.346494 +0:? Linker Objects +0:? 'b' (bool) +0:? 'c' (bool) +0:? 'f' (float) +0:? 'tan' (float) + + +Linked vertex stage: + + + diff --git a/Test/baseResults/120.vert.out b/Test/baseResults/120.vert.out index 9948a0eaa829fce6566a10e3c79b9a5c7c4b6246..4b99b0dc19871fa2782a9e4e3e09f84e57f9921f 100644 --- a/Test/baseResults/120.vert.out +++ b/Test/baseResults/120.vert.out @@ -14,7 +14,7 @@ ERROR: 0:32: 'length' : method does not accept any arguments ERROR: 0:33: 'flizbit' : only the length method is supported for array ERROR: 0:33: '=' : cannot convert from '7-element array of float' to 'int' ERROR: 0:34: 'flizbit' : only the length method is supported for array -ERROR: 0:34: 'f' : no matching overloaded function found +ERROR: 0:34: 'f' : can't use function syntax on variable ERROR: 0:34: 'a4' : redefinition ERROR: 0:35: 'arrays of arrays' : not supported with this profile: none ERROR: 0:36: 'arrays of arrays' : not supported with this profile: none @@ -38,13 +38,14 @@ ERROR: 0:57: 'float' : overloaded functions must have the same return type ERROR: 0:87: 'overloadC' : no matching overloaded function found ERROR: 0:90: 'overloadC' : no matching overloaded function found ERROR: 0:95: 'overloadD' : ambiguous function signature match: multiple signatures match under implicit type conversion +ERROR: 0:98: 'overloadB' : can't use function syntax on variable ERROR: 0:106: 'overloadC' : no matching overloaded function found ERROR: 0:107: 'overloadE' : no matching overloaded function found ERROR: 0:108: 'overloadE' : no matching overloaded function found ERROR: 0:111: 'overloadE' : no matching overloaded function found ERROR: 0:117: 'overloadF' : no matching overloaded function found ERROR: 0:121: 'gl_TexCoord array size' : must be less than gl_MaxTextureCoords (32) -ERROR: 45 compilation errors. No code generated. +ERROR: 46 compilation errors. No code generated. ERROR: node is still EOpNull! @@ -138,10 +139,8 @@ ERROR: node is still EOpNull! 0:95 Function Call: overloadD(f1;i1; (3-component vector of float) 0:95 'i' (int) 0:95 'i' (int) -0:98 Function Call: overloadB(f1;f1; (2-component vector of float) -0:98 Constant: -0:98 1 (const int) -0:98 'i' (int) +0:98 Constant: +0:98 0.000000 0:100 Constant: 0:100 0.000000 0:101 Function Call: texture2D(s21;vf2; (4-component vector of float) diff --git a/Test/baseResults/300scope.vert.out b/Test/baseResults/300scope.vert.out index a51f24aac46d235689db56f308150664545bc1de..c9aefe44f6d166e4e91b1c981cd8010c6cfed4e2 100644 --- a/Test/baseResults/300scope.vert.out +++ b/Test/baseResults/300scope.vert.out @@ -1,21 +1,24 @@ 300scope.vert ERROR: 0:5: 'a' : redefinition ERROR: 0:17: 'b' : function name is redeclaration of existing name -ERROR: 0:19: 'f' : redefinition -ERROR: 0:20: 'tan' : redefinition -ERROR: 0:21: 'redefinition of built-in function' : not supported with this profile: es -ERROR: 0:21: 'sin' : function name is redeclaration of existing name -ERROR: 0:22: 'redefinition of built-in function' : not supported with this profile: es -ERROR: 0:22: 'cos' : function name is redeclaration of existing name -ERROR: 0:22: 'cos' : function already has a body -ERROR: 0:24: 'return' : void function cannot return a value -ERROR: 0:26: 'radians' : function name is redeclaration of existing name -ERROR: 0:26: 'radians' : can't find function -ERROR: 0:28: 'return' : void function cannot return a value -ERROR: 0:35: 'local function declaration' : not supported with this profile: es -ERROR: 0:54: 'z' : undeclared identifier -ERROR: 0:54: 'z' : redefinition -ERROR: 16 compilation errors. No code generated. +ERROR: 0:20: 'c' : redefinition +ERROR: 0:22: 'f' : redefinition +ERROR: 0:23: 'tan' : redefinition +ERROR: 0:24: 'redefinition of built-in function' : not supported with this profile: es +ERROR: 0:24: 'sin' : function name is redeclaration of existing name +ERROR: 0:25: 'redefinition of built-in function' : not supported with this profile: es +ERROR: 0:25: 'cos' : function name is redeclaration of existing name +ERROR: 0:25: 'cos' : function already has a body +ERROR: 0:27: 'return' : void function cannot return a value +ERROR: 0:29: 'radians' : function name is redeclaration of existing name +ERROR: 0:29: 'radians' : can't find function +ERROR: 0:31: 'return' : void function cannot return a value +ERROR: 0:38: 'local function declaration' : not supported with this profile: es +ERROR: 0:43: 'sin' : can't use function syntax on variable +ERROR: 0:57: 'z' : undeclared identifier +ERROR: 0:57: 'z' : redefinition +ERROR: 0:73: 'degrees' : can't use function syntax on variable +ERROR: 19 compilation errors. No code generated. ERROR: node is still EOpNull! @@ -36,87 +39,91 @@ ERROR: node is still EOpNull! 0:8 1.000000 0:11 Branch: Return with expression 0:11 'a' (in highp int) -0:22 Function Definition: cos(f1; (highp float) -0:22 Function Parameters: -0:22 'x' (in highp float) -0:24 Sequence -0:24 Branch: Return with expression -0:24 Constant: -0:24 1.000000 -0:26 Function Definition: radians(b1; (bool) -0:26 Function Parameters: -0:26 'x' (in bool) -0:28 Sequence -0:28 Branch: Return with expression -0:28 Constant: -0:28 true (const bool) -0:33 Function Definition: main( (void) -0:33 Function Parameters: +0:25 Function Definition: cos(f1; (highp float) +0:25 Function Parameters: +0:25 'x' (in highp float) +0:27 Sequence +0:27 Branch: Return with expression +0:27 Constant: +0:27 1.000000 +0:29 Function Definition: radians(b1; (bool) +0:29 Function Parameters: +0:29 'x' (in bool) +0:31 Sequence +0:31 Branch: Return with expression +0:31 Constant: +0:31 true (const bool) +0:36 Function Definition: main( (void) +0:36 Function Parameters: 0:? Sequence -0:36 Function Call: g( (highp int) -0:39 'sin' (highp float) -0:41 Function Call: f(i1;i1;i1; (highp int) -0:41 Constant: -0:41 1 (const int) -0:41 Constant: -0:41 2 (const int) -0:41 Constant: -0:41 3 (const int) -0:44 move second child to first child (highp float) -0:44 'f' (highp float) +0:39 Function Call: g( (highp int) +0:42 'sin' (highp float) +0:43 Constant: +0:43 0.000000 +0:44 Function Call: f(i1;i1;i1; (highp int) 0:44 Constant: -0:44 3.000000 -0:46 move second child to first child (highp 4-component vector of float) -0:46 'gl_Position' (invariant gl_Position highp 4-component vector of float) -0:46 Construct vec4 (highp 4-component vector of float) -0:46 'f' (highp float) -0:48 Sequence -0:48 Sequence -0:48 move second child to first child (highp int) -0:48 'f' (highp int) -0:48 Constant: -0:48 0 (const int) -0:48 Loop with condition tested first -0:48 Loop Condition -0:48 Compare Less Than (bool) -0:48 'f' (highp int) -0:48 Constant: -0:48 10 (const int) -0:48 Loop Body -0:49 Pre-Increment (highp int) -0:49 'f' (highp int) -0:48 Loop Terminal Expression -0:48 Pre-Increment (highp int) -0:48 'f' (highp int) +0:44 1 (const int) +0:44 Constant: +0:44 2 (const int) +0:44 Constant: +0:44 3 (const int) +0:47 move second child to first child (highp float) +0:47 'f' (highp float) +0:47 Constant: +0:47 3.000000 +0:49 move second child to first child (highp 4-component vector of float) +0:49 'gl_Position' (invariant gl_Position highp 4-component vector of float) +0:49 Construct vec4 (highp 4-component vector of float) +0:49 'f' (highp float) 0:51 Sequence -0:51 move second child to first child (highp int) -0:51 'x' (highp int) -0:51 Constant: -0:51 1 (const int) -0:53 Sequence -0:53 Sequence -0:53 move second child to first child (highp float) -0:53 'x' (highp float) -0:53 Constant: -0:53 2.000000 -0:53 move second child to first child (highp float) -0:53 'y' (highp float) -0:53 'x' (highp float) -0:57 Sequence -0:57 Sequence -0:57 move second child to first child (highp int) -0:57 'x' (highp int) -0:57 'x' (highp int) -0:65 Sequence -0:65 Sequence -0:65 move second child to first child (structure{x}) -0:65 'S' (structure{x}) -0:65 Constant: -0:65 0 (const int) -0:66 x: direct index for structure (highp int) -0:66 'S' (structure{x}) -0:66 Constant: -0:66 0 (const int) +0:51 Sequence +0:51 move second child to first child (highp int) +0:51 'f' (highp int) +0:51 Constant: +0:51 0 (const int) +0:51 Loop with condition tested first +0:51 Loop Condition +0:51 Compare Less Than (bool) +0:51 'f' (highp int) +0:51 Constant: +0:51 10 (const int) +0:51 Loop Body +0:52 Pre-Increment (highp int) +0:52 'f' (highp int) +0:51 Loop Terminal Expression +0:51 Pre-Increment (highp int) +0:51 'f' (highp int) +0:54 Sequence +0:54 move second child to first child (highp int) +0:54 'x' (highp int) +0:54 Constant: +0:54 1 (const int) +0:56 Sequence +0:56 Sequence +0:56 move second child to first child (highp float) +0:56 'x' (highp float) +0:56 Constant: +0:56 2.000000 +0:56 move second child to first child (highp float) +0:56 'y' (highp float) +0:56 'x' (highp float) +0:60 Sequence +0:60 Sequence +0:60 move second child to first child (highp int) +0:60 'x' (highp int) +0:60 'x' (highp int) +0:68 Sequence +0:68 Sequence +0:68 move second child to first child (structure{x}) +0:68 'S' (structure{x}) +0:68 Constant: +0:68 0 (const int) +0:69 x: direct index for structure (highp int) +0:69 'S' (structure{x}) +0:69 Constant: +0:69 0 (const int) +0:73 Constant: +0:73 0.000000 0:? Linker Objects 0:? 'b' (bool) 0:? 'gl_VertexID' (gl_VertexId highp int) diff --git a/Test/baseResults/430scope.vert.out b/Test/baseResults/430scope.vert.out index 1dcd5f66a71b1c66fc12cf3b26640e7208aaa6c2..8c56d416df369973d08416d91a8fd7df95a049a3 100644 --- a/Test/baseResults/430scope.vert.out +++ b/Test/baseResults/430scope.vert.out @@ -2,10 +2,13 @@ Warning, version 430 is not yet complete; some version-specific features are present, but many are missing. ERROR: 0:5: 'a' : redefinition ERROR: 0:17: 'b' : function name is redeclaration of existing name -ERROR: 0:19: 'f' : redefinition -ERROR: 0:54: 'z' : undeclared identifier -ERROR: 0:54: 'z' : redefinition -ERROR: 5 compilation errors. No code generated. +ERROR: 0:20: 'c' : redefinition +ERROR: 0:22: 'f' : redefinition +ERROR: 0:43: 'sin' : can't use function syntax on variable +ERROR: 0:57: 'z' : undeclared identifier +ERROR: 0:57: 'z' : redefinition +ERROR: 0:73: 'degrees' : can't use function syntax on variable +ERROR: 8 compilation errors. No code generated. ERROR: node is still EOpNull! @@ -26,90 +29,94 @@ ERROR: node is still EOpNull! 0:8 1.000000 0:11 Branch: Return with expression 0:11 'a' (in int) -0:22 Function Definition: cos(f1; (float) -0:22 Function Parameters: -0:22 'x' (in float) -0:24 Sequence -0:24 Branch: Return with expression -0:24 Constant: -0:24 1.000000 -0:26 Function Definition: radians(b1; (bool) -0:26 Function Parameters: -0:26 'x' (in bool) -0:28 Sequence -0:28 Branch: Return with expression -0:28 Constant: -0:28 true (const bool) -0:33 Function Definition: main( (void) -0:33 Function Parameters: +0:25 Function Definition: cos(f1; (float) +0:25 Function Parameters: +0:25 'x' (in float) +0:27 Sequence +0:27 Branch: Return with expression +0:27 Constant: +0:27 1.000000 +0:29 Function Definition: radians(b1; (bool) +0:29 Function Parameters: +0:29 'x' (in bool) +0:31 Sequence +0:31 Branch: Return with expression +0:31 Constant: +0:31 true (const bool) +0:36 Function Definition: main( (void) +0:36 Function Parameters: 0:? Sequence -0:36 Function Call: g( (int) -0:39 'sin' (float) -0:41 Function Call: f(i1;i1;i1; (int) -0:41 Constant: -0:41 1 (const int) -0:41 Constant: -0:41 2 (const int) -0:41 Constant: -0:41 3 (const int) -0:44 move second child to first child (float) -0:44 'f' (float) +0:39 Function Call: g( (int) +0:42 'sin' (float) +0:43 Constant: +0:43 0.000000 +0:44 Function Call: f(i1;i1;i1; (int) 0:44 Constant: -0:44 3.000000 -0:46 move second child to first child (4-component vector of float) -0:46 gl_Position: direct index for structure (invariant gl_Position 4-component vector of float) -0:46 '__anon__0' (out block{gl_Position,gl_PointSize,gl_ClipDistance,gl_ClipVertex,gl_FrontColor,gl_BackColor,gl_FrontSecondaryColor,gl_BackSecondaryColor,gl_TexCoord,gl_FogFragCoord}) -0:46 Constant: -0:46 0 (const uint) -0:46 Construct vec4 (4-component vector of float) -0:46 'f' (float) -0:48 Sequence -0:48 Sequence -0:48 move second child to first child (int) -0:48 'f' (int) -0:48 Constant: -0:48 0 (const int) -0:48 Loop with condition tested first -0:48 Loop Condition -0:48 Compare Less Than (bool) -0:48 'f' (int) -0:48 Constant: -0:48 10 (const int) -0:48 Loop Body -0:49 Pre-Increment (int) -0:49 'f' (int) -0:48 Loop Terminal Expression -0:48 Pre-Increment (int) -0:48 'f' (int) +0:44 1 (const int) +0:44 Constant: +0:44 2 (const int) +0:44 Constant: +0:44 3 (const int) +0:47 move second child to first child (float) +0:47 'f' (float) +0:47 Constant: +0:47 3.000000 +0:49 move second child to first child (4-component vector of float) +0:49 gl_Position: direct index for structure (invariant gl_Position 4-component vector of float) +0:49 '__anon__0' (out block{gl_Position,gl_PointSize,gl_ClipDistance,gl_ClipVertex,gl_FrontColor,gl_BackColor,gl_FrontSecondaryColor,gl_BackSecondaryColor,gl_TexCoord,gl_FogFragCoord}) +0:49 Constant: +0:49 0 (const uint) +0:49 Construct vec4 (4-component vector of float) +0:49 'f' (float) 0:51 Sequence -0:51 move second child to first child (int) -0:51 'x' (int) -0:51 Constant: -0:51 1 (const int) -0:53 Sequence -0:53 Sequence -0:53 move second child to first child (float) -0:53 'x' (float) -0:53 Constant: -0:53 2.000000 -0:53 move second child to first child (float) -0:53 'y' (float) -0:53 'x' (float) -0:57 Sequence -0:57 Sequence -0:57 move second child to first child (int) -0:57 'x' (int) -0:57 'x' (int) -0:65 Sequence -0:65 Sequence -0:65 move second child to first child (structure{x}) -0:65 'S' (structure{x}) -0:65 Constant: -0:65 0 (const int) -0:66 x: direct index for structure (int) -0:66 'S' (structure{x}) -0:66 Constant: -0:66 0 (const int) +0:51 Sequence +0:51 move second child to first child (int) +0:51 'f' (int) +0:51 Constant: +0:51 0 (const int) +0:51 Loop with condition tested first +0:51 Loop Condition +0:51 Compare Less Than (bool) +0:51 'f' (int) +0:51 Constant: +0:51 10 (const int) +0:51 Loop Body +0:52 Pre-Increment (int) +0:52 'f' (int) +0:51 Loop Terminal Expression +0:51 Pre-Increment (int) +0:51 'f' (int) +0:54 Sequence +0:54 move second child to first child (int) +0:54 'x' (int) +0:54 Constant: +0:54 1 (const int) +0:56 Sequence +0:56 Sequence +0:56 move second child to first child (float) +0:56 'x' (float) +0:56 Constant: +0:56 2.000000 +0:56 move second child to first child (float) +0:56 'y' (float) +0:56 'x' (float) +0:60 Sequence +0:60 Sequence +0:60 move second child to first child (int) +0:60 'x' (int) +0:60 'x' (int) +0:68 Sequence +0:68 Sequence +0:68 move second child to first child (structure{x}) +0:68 'S' (structure{x}) +0:68 Constant: +0:68 0 (const int) +0:69 x: direct index for structure (int) +0:69 'S' (structure{x}) +0:69 Constant: +0:69 0 (const int) +0:73 Constant: +0:73 0.000000 0:? Linker Objects 0:? 'b' (bool) 0:? 'tan' (float) diff --git a/Test/testlist b/Test/testlist index f79b118300963961bd68b5255905627a317b3cce..f32ea4ee5bfda61b2feba84c7b3056798517cc5c 100644 --- a/Test/testlist +++ b/Test/testlist @@ -45,6 +45,7 @@ switch.frag tokenLength.vert 100Limits.vert 100scope.vert +110scope.vert 300scope.vert 400.frag 420.vert diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h index 2a3880828d323d1641ca31db4669044c84458625..7df6a5d5a9003667ae018b1bb84a480c9ac2f61e 100644 --- a/glslang/Include/revision.h +++ b/glslang/Include/revision.h @@ -9,5 +9,5 @@ // source have to figure out how to create revision.h just to get a build // going. However, if it is not updated, it can be a version behind. -#define GLSLANG_REVISION "24420" -#define GLSLANG_DATE "2013/12/09 17:25:14" +#define GLSLANG_REVISION "24468" +#define GLSLANG_DATE "2013/12/11 11:57:40" diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 7fe112970e08d93f5059ccc93d138f20486947ff..10edd0ac910855b55c234d75ba990341eb5c4fd1 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -2904,6 +2904,11 @@ const TFunction* TParseContext::findFunction(TSourceLoc loc, const TFunction& ca { const TFunction* function = 0; + if (symbolTable.isFunctionNameVariable(call.getName())) { + error(loc, "can't use function syntax on variable", call.getName().c_str(), ""); + return 0; + } + if (profile == EEsProfile || version < 120) function = findFunctionExact(loc, call, builtIn); else if (version < 400) diff --git a/glslang/MachineIndependent/ShaderLang.cpp b/glslang/MachineIndependent/ShaderLang.cpp index c7a0aa91bae3080de0b8e46b6953efd20ed4e758..53f9451edd3c94c672ea7e6816defdbc2bb225cb 100644 --- a/glslang/MachineIndependent/ShaderLang.cpp +++ b/glslang/MachineIndependent/ShaderLang.cpp @@ -170,6 +170,8 @@ void InitializeStageSymbolTable(TBuiltIns& builtIns, int version, EProfile profi IdentifyBuiltIns(version, profile, language, *symbolTables[language]); if (profile == EEsProfile && version >= 300) (*symbolTables[language]).setNoBuiltInRedeclarations(); + if (version == 110) + (*symbolTables[language]).setSeparateNameSpaces(); } // diff --git a/glslang/MachineIndependent/SymbolTable.cpp b/glslang/MachineIndependent/SymbolTable.cpp index 9c18a7a3e824da654468b7d37990c17c9049548c..1384c466046f68d204e83712a25aaeb7181eaa9d 100644 --- a/glslang/MachineIndependent/SymbolTable.cpp +++ b/glslang/MachineIndependent/SymbolTable.cpp @@ -322,11 +322,11 @@ TSymbolTableLevel* TSymbolTableLevel::clone() const TVariable* container = anon->getAnonContainer().clone(); container->changeName(NewPoolTString("")); // insert the whole container - symTableLevel->insert(*container); + symTableLevel->insert(*container, false); containerCopied[anon->getAnonId()] = true; } } else - symTableLevel->insert(*iter->second->clone()); + symTableLevel->insert(*iter->second->clone(), false); } return symTableLevel; @@ -338,6 +338,7 @@ void TSymbolTable::copyTable(const TSymbolTable& copyOf) uniqueId = copyOf.uniqueId; noBuiltInRedeclarations = copyOf.noBuiltInRedeclarations; + separateNameSpaces = copyOf.separateNameSpaces; for (unsigned int i = copyOf.adoptedLevels; i < copyOf.table.size(); ++i) table.push_back(copyOf.table[i]->clone()); } diff --git a/glslang/MachineIndependent/SymbolTable.h b/glslang/MachineIndependent/SymbolTable.h index 71f07f5c1900b7b9ff883c7fd8b4b0b85880162f..7dac826f4c78989c8faed2123e3d40901be91192 100644 --- a/glslang/MachineIndependent/SymbolTable.h +++ b/glslang/MachineIndependent/SymbolTable.h @@ -283,7 +283,7 @@ public: TSymbolTableLevel() : defaultPrecision(0), anonId(0) { } ~TSymbolTableLevel(); - bool insert(TSymbol& symbol) + bool insert(TSymbol& symbol, bool separateNameSpaces) { // // returning true means symbol was added to the table with no semantic errors @@ -316,7 +316,7 @@ public: const TString& insertName = symbol.getMangledName(); if (symbol.getAsFunction()) { // make sure there isn't a variable of this name - if (level.find(name) != level.end()) + if (! separateNameSpaces && level.find(name) != level.end()) return false; // insert, and whatever happens is okay @@ -367,6 +367,34 @@ public: return false; } + // See if there is a variable at this level having the given non-function-style name. + // Return true if name is found, and set variable to true if the name was a variable. + bool findFunctionVariableName(const TString& name, bool& variable) const + { + tLevel::const_iterator candidate = level.lower_bound(name); + if (candidate != level.end()) { + const TString& candidateName = (*candidate).first; + TString::size_type parenAt = candidateName.find_first_of('('); + if (parenAt == candidateName.npos) { + // not a mangled name + if (candidateName == name) { + // found a variable name match + variable = true; + return true; + } + } else { + // a mangled name + if (candidateName.compare(0, parenAt, name) == 0) { + // found a function name match + variable = false; + return true; + } + } + } + + return false; + } + // Use this to do a lazy 'push' of precision defaults the first time // a precision statement is seen in a new scope. Leave it at 0 for // when no push was needed. Thus, it is not the current defaults, @@ -415,7 +443,7 @@ protected: class TSymbolTable { public: - TSymbolTable() : uniqueId(0), noBuiltInRedeclarations(false), adoptedLevels(0) + TSymbolTable() : uniqueId(0), noBuiltInRedeclarations(false), separateNameSpaces(false), adoptedLevels(0) { // // This symbol table cannot be used until push() is called. @@ -438,6 +466,7 @@ public: } uniqueId = symTable.uniqueId; noBuiltInRedeclarations = symTable.noBuiltInRedeclarations; + separateNameSpaces = symTable.separateNameSpaces; } // @@ -459,6 +488,7 @@ public: bool atGlobalLevel() { return isGlobalLevel(currentLevel()); } void setNoBuiltInRedeclarations() { noBuiltInRedeclarations = true; } + void setSeparateNameSpaces() { separateNameSpaces = true; } void push() { @@ -477,7 +507,7 @@ public: symbol.setUniqueId(++uniqueId); // make sure there isn't a function of this variable name - if (! symbol.getAsFunction() && table[currentLevel()]->hasFunctionName(symbol.getName())) + if (! separateNameSpaces && ! symbol.getAsFunction() && table[currentLevel()]->hasFunctionName(symbol.getName())) return false; // check for not overloading or redefining a built-in function @@ -490,7 +520,7 @@ public: } } - return table[currentLevel()]->insert(symbol); + return table[currentLevel()]->insert(symbol, separateNameSpaces); } // @@ -517,12 +547,12 @@ public: TSymbol* copyUp(TSymbol* shared) { TSymbol* copy = copyUpDeferredInsert(shared); - table[globalLevel]->insert(*copy); + table[globalLevel]->insert(*copy, separateNameSpaces); if (shared->getAsVariable()) return copy; else { // get copy of an anonymous member's container - table[currentLevel()]->insert(*copy); + table[currentLevel()]->insert(*copy, separateNameSpaces); // return the copy of the anonymous member return table[currentLevel()]->find(shared->getName()); } @@ -545,6 +575,23 @@ public: return symbol; } + bool isFunctionNameVariable(const TString& name) const + { + if (separateNameSpaces) + return false; + + int level = currentLevel(); + do { + bool variable; + bool found = table[level]->findFunctionVariableName(name, variable); + if (found) + return variable; + --level; + } while (level >= 0); + + return false; + } + void findFunctionNameList(const TString& name, TVector<TFunction*>& list, bool& builtIn) { // For user levels, return the set found in the first scope with a match @@ -606,6 +653,7 @@ protected: std::vector<TSymbolTableLevel*> table; int uniqueId; // for unique identification in code generation bool noBuiltInRedeclarations; + bool separateNameSpaces; unsigned int adoptedLevels; }; diff --git a/glslang/MachineIndependent/linkValidate.cpp b/glslang/MachineIndependent/linkValidate.cpp index e3c13eb8d85aa5089acb8c2586b7b21c439d3b16..74394c506a905173d54b4393fae3bf490c86f416 100644 --- a/glslang/MachineIndependent/linkValidate.cpp +++ b/glslang/MachineIndependent/linkValidate.cpp @@ -91,7 +91,7 @@ void TIntermediate::merge(TInfoSink& infoSink, TIntermediate& unit) else if (vertices != unit.vertices) error(infoSink, "Contradictory layout max_vertices values"); - if (vertexSpacing == ElgNone) + if (vertexSpacing == EvsNone) vertexSpacing = unit.vertexSpacing; else if (vertexSpacing != unit.vertexSpacing) error(infoSink, "Contradictory input vertex spacing");