aboutsummaryrefslogtreecommitdiff
path: root/Test
diff options
context:
space:
mode:
authorJohn Kessenich <cepheus@frii.com>2013-10-17 20:55:30 +0000
committerJohn Kessenich <cepheus@frii.com>2013-10-17 20:55:30 +0000
commite46b087760ed2b4eb0805302d9f314f612282de5 (patch)
tree040f812c832113a1ddebf2ffc1d1d743ba2e59d3 /Test
parent779e6b406a3962258d744986fdda944f03cbb85d (diff)
downloadglslang-e46b087760ed2b4eb0805302d9f314f612282de5.tar.gz
Add function "const", where the initializer does not have to be a compile-time constant.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@23566 e7fa87d3-cd2b-0410-9028-fcbf551c1848
Diffstat (limited to 'Test')
-rw-r--r--Test/420.vert17
-rw-r--r--Test/baseResults/120.vert.out12
-rw-r--r--Test/baseResults/420.tese.out7
-rw-r--r--Test/baseResults/420.vert.out83
-rw-r--r--Test/baseResults/array.frag.out2
-rw-r--r--Test/baseResults/constErrors.frag.out13
-rw-r--r--Test/baseResults/matrixError.vert.out2
-rw-r--r--Test/baseResults/specExamples.frag.out19
-rw-r--r--Test/baseResults/specExamples.vert.out12
-rw-r--r--Test/baseResults/uint.frag.out8
-rw-r--r--Test/constErrors.frag2
11 files changed, 110 insertions, 67 deletions
diff --git a/Test/420.vert b/Test/420.vert
index 3f4fa699..04dd1709 100644
--- a/Test/420.vert
+++ b/Test/420.vert
@@ -12,6 +12,23 @@ smooth flat out vec4 rep; // ERROR, replicating interpolation qualification
centroid sample out vec4 rep2; // ERROR, replicating auxiliary qualification
in uniform vec4 rep3; // ERROR, replicating storage qualification
+int anonconst;
+const int aconst = 5;
+const int a = aconst;
+const int b = anonconst; // ERROR at global scope
+
+const int foo() // ERROR, no const functions
+{
+ const int a = aconst;
+ const int b = anonconst;
+ const int c = a; // still compile-time const
+ const int d = b; // not a compile-time const
+ float x[c]; // okay
+ float y[d]; // ERROR
+
+ return b;
+}
+
void main()
{
int i;
diff --git a/Test/baseResults/120.vert.out b/Test/baseResults/120.vert.out
index bb956dea..9f499f87 100644
--- a/Test/baseResults/120.vert.out
+++ b/Test/baseResults/120.vert.out
@@ -24,14 +24,16 @@ ERROR: 0:39: 'arrays of arrays' : not supported with this profile: none
ERROR: 0:40: 'arrays of arrays' : not supported with this profile: none
ERROR: 0:40: 'constructor' : array constructor needs one argument per array element
ERROR: 0:40: 'arrays of arrays' : not supported with this profile: none
+ERROR: 0:40: '=' : cannot convert from 'const float' to '2-element array of float'
ERROR: 0:41: 'arrays of arrays' : not supported with this profile: none
ERROR: 0:41: 'constructor' : array constructor needs one argument per array element
ERROR: 0:41: 'arrays of arrays' : not supported with this profile: none
+ERROR: 0:41: '=' : cannot convert from 'const float' to '2-element array of float'
ERROR: 0:50: 'arrays of arrays' : not supported with this profile: none
ERROR: 0:51: 'arrays of arrays' : not supported with this profile: none
ERROR: 0:52: 'arrays of arrays' : not supported with this profile: none
ERROR: 0:53: 'arrays of arrays' : not supported with this profile: none
-ERROR: 32 compilation errors. No code generated.
+ERROR: 34 compilation errors. No code generated.
ERROR: node is still EOpNull!
0:15 Function Definition: main( (void)
@@ -75,14 +77,6 @@ ERROR: node is still EOpNull!
0:32 'a3' (int)
0:32 Constant:
0:32 12 (const int)
-0:40 Sequence
-0:40 move second child to first child (2-element array of float)
-0:40 'md9' (2-element array of float)
-0:40 Construct float (const 2-element array of float)
-0:41 Sequence
-0:41 move second child to first child (2-element array of float)
-0:41 'md11' (2-element array of float)
-0:41 Construct float (const 2-element array of float)
0:43 move second child to first child (float)
0:43 'gl_PointSize' (invariant gl_PointSize float)
0:43 Constant:
diff --git a/Test/baseResults/420.tese.out b/Test/baseResults/420.tese.out
index 415129bf..2b5af43d 100644
--- a/Test/baseResults/420.tese.out
+++ b/Test/baseResults/420.tese.out
@@ -8,10 +8,11 @@ ERROR: 0:27: '=' : cannot convert from 'const bool' to 'int'
ERROR: 0:28: 'constructor' : cannot convert parameter 2 from 'const float' to '4-component vector of float'
ERROR: 0:29: 'constructor' : cannot convert parameter 2 from 'const 2X2 matrix of float' to 'const 4-component vector of float'
ERROR: 0:29: 'const 2-element array of 4-component vector of float' : cannot construct with these arguments
+ERROR: 0:29: '=' : cannot convert from 'const float' to '2-element array of 4-component vector of float'
ERROR: 0:30: 'initializer list' : wrong number of matrix columns: 4X2 matrix of float
ERROR: 0:40: 'constructor' : cannot convert parameter 1 from 'float' to 'structure'
ERROR: 0:58: 'initializer list' : wrong number of structure members
-ERROR: 12 compilation errors. No code generated.
+ERROR: 13 compilation errors. No code generated.
ERROR: node is still EOpNull!
0:4 Sequence
@@ -34,10 +35,6 @@ ERROR: node is still EOpNull!
0:20 Constant:
0:20 1.000000
0:20 3 (const int)
-0:29 Sequence
-0:29 move second child to first child (2-element array of 4-component vector of float)
-0:29 'b4' (2-element array of 4-component vector of float)
-0:29 Construct vec4 (const 2-element array of 4-component vector of float)
0:42 Sequence
0:42 move second child to first child (5-element array of float)
0:42 'b5' (5-element array of float)
diff --git a/Test/baseResults/420.vert.out b/Test/baseResults/420.vert.out
index 6703561a..4201808d 100644
--- a/Test/baseResults/420.vert.out
+++ b/Test/baseResults/420.vert.out
@@ -5,39 +5,56 @@ ERROR: 0:7: '' : vertex input cannot be further qualified
ERROR: 0:11: '' : can only have one interpolation qualifier (flat, smooth, noperspective)
ERROR: 0:12: '' : can only have one auxiliary qualifier (centroid, patch, and sample)
ERROR: 0:13: 'uniform' : too many storage qualifiers
-ERROR: 0:21: 'j' : undeclared identifier
-ERROR: 0:21: '=' : cannot convert from 'float' to 'int'
-ERROR: 0:22: 'k' : undeclared identifier
-ERROR: 0:22: '=' : cannot convert from 'float' to 'int'
-ERROR: 0:23: 'j' : undeclared identifier
-ERROR: 0:23: '=' : cannot convert from 'float' to 'int'
-ERROR: 0:27: 'jj' : undeclared identifier
-ERROR: 0:27: '=' : cannot convert from 'float' to 'int'
-ERROR: 13 compilation errors. No code generated.
+ERROR: 0:18: '=' : global const initializers must be constant 'const int'
+ERROR: 0:20: 'const' : no qualifiers allowed for function return
+ERROR: 0:27: '' : constant expression required
+ERROR: 0:27: '' : array size must be a constant integer expression
+ERROR: 0:38: 'j' : undeclared identifier
+ERROR: 0:38: '=' : cannot convert from 'float' to 'int'
+ERROR: 0:39: 'k' : undeclared identifier
+ERROR: 0:39: '=' : cannot convert from 'float' to 'int'
+ERROR: 0:40: 'j' : undeclared identifier
+ERROR: 0:40: '=' : cannot convert from 'float' to 'int'
+ERROR: 0:44: 'jj' : undeclared identifier
+ERROR: 0:44: '=' : cannot convert from 'float' to 'int'
+ERROR: 17 compilation errors. No code generated.
ERROR: node is still EOpNull!
-0:15 Function Definition: main( (void)
-0:15 Function Parameters:
+0:20 Function Definition: foo( (const int)
+0:20 Function Parameters:
0:? Sequence
-0:18 Test condition and select (void)
-0:18 Condition
-0:18 Compare Equal (bool)
-0:18 'i' (int)
-0:18 Constant:
-0:18 3 (const int)
-0:18 true case
-0:19 Sequence
-0:19 move second child to first child (int)
-0:19 'j' (int)
-0:19 'i' (int)
-0:25 Loop with condition tested first
-0:25 Loop Condition
-0:25 Constant:
-0:25 true (const bool)
-0:25 No loop body
-0:30 Function Definition: bar(vf4; (void)
-0:30 Function Parameters:
-0:30 'v' (in 4-component vector of float)
+0:23 Sequence
+0:23 move second child to first child (int)
+0:23 'b' (const (read only) int)
+0:23 'anonconst' (int)
+0:25 Sequence
+0:25 move second child to first child (int)
+0:25 'd' (const (read only) int)
+0:25 'b' (const (read only) int)
+0:29 Branch: Return with expression
+0:29 'b' (const (read only) int)
+0:32 Function Definition: main( (void)
+0:32 Function Parameters:
+0:? Sequence
+0:35 Test condition and select (void)
+0:35 Condition
+0:35 Compare Equal (bool)
+0:35 'i' (int)
+0:35 Constant:
+0:35 3 (const int)
+0:35 true case
+0:36 Sequence
+0:36 move second child to first child (int)
+0:36 'j' (int)
+0:36 'i' (int)
+0:42 Loop with condition tested first
+0:42 Loop Condition
+0:42 Constant:
+0:42 true (const bool)
+0:42 No loop body
+0:47 Function Definition: bar(vf4; (void)
+0:47 Function Parameters:
+0:47 'v' (in 4-component vector of float)
0:? Linker Objects
0:? 'v2' (smooth out 2-component vector of float)
0:? 'bad' (in 10-element array of 4-component vector of float)
@@ -48,6 +65,12 @@ ERROR: node is still EOpNull!
0:? 'rep' (smooth flat out 4-component vector of float)
0:? 'rep2' (centroid smooth sample out 4-component vector of float)
0:? 'rep3' (in 4-component vector of float)
+0:? 'anonconst' (int)
+0:? 'aconst' (const int)
+0:? 5 (const int)
+0:? 'a' (const int)
+0:? 5 (const int)
+0:? 'b' (int)
0:? 'gl_VertexID' (gl_VertexId int)
0:? 'gl_InstanceID' (gl_InstanceId int)
diff --git a/Test/baseResults/array.frag.out b/Test/baseResults/array.frag.out
index b87a9bf0..36401844 100644
--- a/Test/baseResults/array.frag.out
+++ b/Test/baseResults/array.frag.out
@@ -8,7 +8,7 @@ ERROR: 0:42: '[' : array index out of range '5'
ERROR: 0:45: '[' : array index out of range '1000'
ERROR: 0:46: '[' : array index out of range '-1'
ERROR: 0:52: '[' : array index '2' out of range
-ERROR: 0:54: 'const' : non-matching types for const initializer
+ERROR: 0:54: 'const' : non-matching or non-convertible constant type for const initializer
ERROR: 0:56: '=' : cannot convert from 'const 2-element array of int' to '3-element array of int'
ERROR: 0:57: '[]' : scalar integer expression required
ERROR: 0:57: '[' : array index out of range '-858993459'
diff --git a/Test/baseResults/constErrors.frag.out b/Test/baseResults/constErrors.frag.out
index bd249e2f..48ec2499 100644
--- a/Test/baseResults/constErrors.frag.out
+++ b/Test/baseResults/constErrors.frag.out
@@ -1,18 +1,23 @@
Warning, version 330 is not yet complete; some version-specific features are present, but many are missing.
-ERROR: 0:14: '=' : assigning non-constant to 'const int'
+ERROR: 0:14: 'non-constant initializer' : not supported for this version or the enabled extensions
ERROR: 0:17: '' : constant expression required
ERROR: 0:17: '' : array size must be a constant integer expression
ERROR: 0:18: '' : constant expression required
ERROR: 0:18: '' : array size must be a constant integer expression
ERROR: 0:19: '' : constant expression required
ERROR: 0:19: '' : array size must be a constant integer expression
-ERROR: 0:27: '=' : assigning non-constant to 'const structure'
-ERROR: 0:33: '=' : assigning non-constant to 'const structure'
+ERROR: 0:27: '=' : global const initializers must be constant 'const structure'
+ERROR: 0:33: '=' : global const initializers must be constant 'const structure'
ERROR: 9 compilation errors. No code generated.
ERROR: node is still EOpNull!
0:10 Function Definition: main( (void)
0:10 Function Parameters:
+0:? Sequence
+0:14 Sequence
+0:14 move second child to first child (int)
+0:14 'a3' (const (read only) int)
+0:14 'uniformInt' (uniform int)
0:? Linker Objects
0:? 'inVar' (smooth in 4-component vector of float)
0:? 'outVar' (out 4-component vector of float)
@@ -21,4 +26,6 @@ ERROR: node is still EOpNull!
0:? 'uniformInt' (uniform int)
0:? 's' (structure)
0:? 's2' (structure)
+0:? 'f' (const float)
+0:? 3.000000
diff --git a/Test/baseResults/matrixError.vert.out b/Test/baseResults/matrixError.vert.out
index 65f623e4..fa5a82bd 100644
--- a/Test/baseResults/matrixError.vert.out
+++ b/Test/baseResults/matrixError.vert.out
@@ -1,6 +1,6 @@
Warning, version 120 is not yet complete; most features are present, but a few are missing.
ERROR: 0:10: 'constructor' : too many arguments
-ERROR: 0:7: '=' : cannot assign to 'const 2X4 matrix of float'
+ERROR: 0:7: 'const' : non-matching or non-convertible constant type for const initializer
ERROR: 0:17: 'assign' : cannot convert from '2-component vector of float' to '3-component vector of float'
ERROR: 0:18: 'assign' : cannot convert from '2-component vector of float' to '3-component vector of float'
ERROR: 0:19: '.' : field selection not allowed on matrix
diff --git a/Test/baseResults/specExamples.frag.out b/Test/baseResults/specExamples.frag.out
index 9eb9566b..a0e46f84 100644
--- a/Test/baseResults/specExamples.frag.out
+++ b/Test/baseResults/specExamples.frag.out
@@ -22,6 +22,7 @@ ERROR: 0:115: 'depth_greater' : unrecognized layout identifier
ERROR: 0:118: 'depth_less' : unrecognized layout identifier
ERROR: 0:121: 'depth_unchanged' : unrecognized layout identifier
ERROR: 0:150: 'constructor' : constructing from a non-dereferenced array
+ERROR: 0:150: '=' : cannot convert from 'const float' to '3-element array of 4-component vector of float'
ERROR: 0:152: 'constructor' : cannot convert parameter 1 from 'const 2-element array of 4-component vector of float' to '4-component vector of float'
ERROR: 0:172: 'x' : undeclared identifier
ERROR: 0:172: '[]' : scalar integer expression required
@@ -42,16 +43,12 @@ ERROR: 0:178: 'a' : dot operator requires structure, array, vector, or matrix o
ERROR: 0:178: 'length' : dot operator requires structure, array, vector, or matrix on left hand side
ERROR: 0:178: '' : function call, method, or subroutine call expected
ERROR: 0:178: '' : no matching overloaded function found
-ERROR: 0:193: '=' : cannot convert from 'const int' to 'structure'
ERROR: 0:198: 'e' : redefinition
-ERROR: 0:217: '=' : cannot convert from 'const float' to 'unsized array of float'
-ERROR: 0:219: '=' : cannot convert from 'unsized array of float' to '5-element array of float'
-ERROR: 0:223: '=' : assigning non-constant to 'const float'
ERROR: 0:226: 'in' : not allowed in nested scope
ERROR: 0:227: 'in' : not allowed in nested scope
ERROR: 0:228: 'in' : not allowed in nested scope
ERROR: 0:232: 'out' : not allowed in nested scope
-ERROR: 52 compilation errors. No code generated.
+ERROR: 49 compilation errors. No code generated.
ERROR: node is still EOpNull!
0:5 Sequence
@@ -166,10 +163,6 @@ ERROR: node is still EOpNull!
0:149 0.100000
0:149 0.100000
0:149 0.100000
-0:150 Sequence
-0:150 move second child to first child (3-element array of 4-component vector of float)
-0:150 'a3' (3-element array of 4-component vector of float)
-0:150 Construct vec4 (3-element array of 4-component vector of float)
0:? Sequence
0:159 Sequence
0:159 Sequence
@@ -235,6 +228,14 @@ ERROR: node is still EOpNull!
0:219 move second child to first child (5-element array of float)
0:219 'd' (5-element array of float)
0:219 'b' (5-element array of float)
+0:? Sequence
+0:223 Sequence
+0:223 move second child to first child (float)
+0:223 'ceiling' (const (read only) float)
+0:223 Convert int to float (float)
+0:223 add (int)
+0:223 'a' (int)
+0:223 'b' (int)
0:? Linker Objects
0:? 'a' (int)
0:? 'b' (int)
diff --git a/Test/baseResults/specExamples.vert.out b/Test/baseResults/specExamples.vert.out
index 5edf37f6..c06df108 100644
--- a/Test/baseResults/specExamples.vert.out
+++ b/Test/baseResults/specExamples.vert.out
@@ -46,11 +46,10 @@ ERROR: 0:164: 'func' : no matching overloaded function found
ERROR: 0:166: 'x' : dot operator requires structure, array, vector, or matrix on left hand side
ERROR: 0:166: 'func2' : no matching overloaded function found
ERROR: 0:167: 'x' : dot operator requires structure, array, vector, or matrix on left hand side
-ERROR: 0:191: '=' : cannot convert from 'const 4-component vector of float' to '2-element array of 4-component vector of float'
ERROR: 0:192: 'constructor' : constructing from a non-dereferenced array
ERROR: 0:193: 'constructor' : constructing from a non-dereferenced array
ERROR: 0:194: 'constructor' : constructing from a non-dereferenced array
-ERROR: 51 compilation errors. No code generated.
+ERROR: 50 compilation errors. No code generated.
ERROR: node is still EOpNull!
0:134 Function Definition: funcA(I21; (4-component vector of float)
@@ -244,9 +243,12 @@ ERROR: node is still EOpNull!
0:191 1.000000
0:191 1.000000
0:191 1.000000
-0:192 Construct vec4 (3-element array of 4-component vector of float)
-0:193 Construct vec4 (3-element array of 4-component vector of float)
-0:194 Construct vec4 (3-element array of 4-component vector of float)
+0:192 Constant:
+0:192 0.000000
+0:193 Constant:
+0:193 0.000000
+0:194 Constant:
+0:194 0.000000
0:? Linker Objects
0:? 'Coords' (out block)
0:? '__anon__0' (out block)
diff --git a/Test/baseResults/uint.frag.out b/Test/baseResults/uint.frag.out
index 2a14b8ad..428df239 100644
--- a/Test/baseResults/uint.frag.out
+++ b/Test/baseResults/uint.frag.out
@@ -1,9 +1,9 @@
ERROR: 0:2: 'uint' : must be qualified as flat in
ERROR: 0:6: 'in' : cannot be bool
-ERROR: 0:20: 'const' : non-matching types for const initializer
-ERROR: 0:24: 'const' : non-matching types for const initializer
-ERROR: 0:34: 'const' : non-matching types for const initializer
-ERROR: 0:37: 'const' : non-matching types for const initializer
+ERROR: 0:20: 'const' : non-matching or non-convertible constant type for const initializer
+ERROR: 0:24: 'const' : non-matching or non-convertible constant type for const initializer
+ERROR: 0:34: 'const' : non-matching or non-convertible constant type for const initializer
+ERROR: 0:37: 'const' : non-matching or non-convertible constant type for const initializer
ERROR: 0:48: '=' : cannot convert from 'const int' to 'mediump uint'
ERROR: 0:51: '=' : cannot convert from 'const int' to 'mediump uint'
ERROR: 0:63: 'float' : type requires declaration of default precision qualifier
diff --git a/Test/constErrors.frag b/Test/constErrors.frag
index df49afcd..0067af11 100644
--- a/Test/constErrors.frag
+++ b/Test/constErrors.frag
@@ -31,3 +31,5 @@ const struct S2 {
ivec2 iv2;
mat2x4 m;
} s2 = S2(vec3(3.0), ivec2(3, constInt), mat2x4(1.0, 2.0, 3.0, inVar.x, 5.0, 6.0, 7.0, 8.0)); // ERROR, non-constant matrix
+
+const float f = 3; // okay, type conversion