diff --git a/Test/100.frag b/Test/100.frag index 409791604504b66025c6f24f487fa85755b8f865..ce6a6eec5550777584ca03d505040bec5af41e0c 100644 --- a/Test/100.frag +++ b/Test/100.frag @@ -1,6 +1,6 @@ // okay #version 100 -int a[3] = { 2, 3, 4, }; // ERROR +int a[3] = { 2, 3, 4, }; // ERROR (lots) #version 100 int uint; @@ -194,6 +194,25 @@ void badswizzle() a.method(); // ERROR } +float fooinit(); + +float fooinittest() +{ + return fooinit(); +} + +// Test extra-function initializers +const float fi1 = 3.0; +const float fi2 = 4.0; +const float fi3 = 5.0; + +float fooinit() +{ + return fi1 + fi2 + fi3; // should make a constant of 12.0 +} + +int init1 = gl_FrontFacing ? 1 : 2; // ERROR, non-const initializer + #pragma STDGL invariant(all) #line 3000 diff --git a/Test/140.frag b/Test/140.frag index 0abc574fd86ae315a20a2d539ab9b1e5a6c6a704..2bc2f59fe0c2a6df37d8d107f59f7137fdddcaab 100644 --- a/Test/140.frag +++ b/Test/140.frag @@ -33,8 +33,21 @@ layout(location = 5) out vec4 factor; layout(location=4) in vec4 vl2; +float fooi(); + void foo() { vec2 r1 = modf(v.xy, v.zw); // ERROR, v.zw not l-value vec2 r2 = modf(o.xy, o.zw); + o.z = fooi(); +} + +// Test extra-function initializers + +float i1 = gl_FrontFacing ? -2.0 : 2.0; +float i2 = 102; + +float fooi() +{ + return i1 + i2; } diff --git a/Test/baseResults/100.frag.out b/Test/baseResults/100.frag.out index 30af8cea22c01bb5ec9738ae57f7249d7c520726..ae50dcb0b28d81ace484ea97b030be7139536654 100644 --- a/Test/baseResults/100.frag.out +++ b/Test/baseResults/100.frag.out @@ -2,6 +2,7 @@ ERROR: 0:3: '{ } style initializers' : not supported with this profile: es ERROR: 0:3: 'initializer' : not supported for this version or the enabled extensions ERROR: 0:3: 'array initializer' : not supported for this version or the enabled extensions +ERROR: 0:3: 'non-constant global initializer' : not supported with this profile: es ERROR: 0:4: '#version' : must occur first in shader ERROR: 0:7: 'attribute' : not supported in this stage: fragment ERROR: 0:7: 'float' : type requires declaration of default precision qualifier @@ -82,9 +83,10 @@ ERROR: 0:192: '.' : cannot apply to an array: nothing ERROR: 0:193: '.length' : not supported for this version or the enabled extensions ERROR: 0:194: '.' : cannot apply to an array: method ERROR: 0:194: 'a' : can't use function syntax on variable +ERROR: 0:214: 'non-constant global initializer' : not supported with this profile: es ERROR: 0:3000: '#error' : line of this error should be 3000 ERROR: 0:3002: '' : syntax error -ERROR: 76 compilation errors. No code generated. +ERROR: 78 compilation errors. No code generated. Shader version: 100 @@ -352,6 +354,29 @@ ERROR: node is still EOpNull! 0:193 5 (const int) 0:194 Constant: 0:194 0.000000 +0:199 Function Definition: fooinittest( (global mediump float) +0:199 Function Parameters: +0:201 Sequence +0:201 Branch: Return with expression +0:201 Function Call: fooinit( (global mediump float) +0:209 Function Definition: fooinit( (global mediump float) +0:209 Function Parameters: +0:211 Sequence +0:211 Branch: Return with expression +0:211 Constant: +0:211 12.000000 +0:214 Sequence +0:214 move second child to first child (temp mediump int) +0:214 'init1' (global mediump int) +0:214 Test condition and select (temp mediump int) +0:214 Condition +0:214 'gl_FrontFacing' (gl_FrontFacing bool) +0:214 true case +0:214 Constant: +0:214 1 (const int) +0:214 false case +0:214 Constant: +0:214 2 (const int) 0:? Linker Objects 0:? 'a' (global 3-element array of mediump int) 0:? 'uint' (global mediump int) @@ -376,6 +401,13 @@ ERROR: node is still EOpNull! 0:? 'f124' (global mediump float) 0:? 'sCube' (uniform lowp samplerCube) 0:? 's' (smooth in structure{global mediump float f}) +0:? 'fi1' (const mediump float) +0:? 3.000000 +0:? 'fi2' (const mediump float) +0:? 4.000000 +0:? 'fi3' (const mediump float) +0:? 5.000000 +0:? 'init1' (global mediump int) Linked fragment stage: @@ -646,6 +678,29 @@ ERROR: node is still EOpNull! 0:193 5 (const int) 0:194 Constant: 0:194 0.000000 +0:199 Function Definition: fooinittest( (global mediump float) +0:199 Function Parameters: +0:201 Sequence +0:201 Branch: Return with expression +0:201 Function Call: fooinit( (global mediump float) +0:209 Function Definition: fooinit( (global mediump float) +0:209 Function Parameters: +0:211 Sequence +0:211 Branch: Return with expression +0:211 Constant: +0:211 12.000000 +0:214 Sequence +0:214 move second child to first child (temp mediump int) +0:214 'init1' (global mediump int) +0:214 Test condition and select (temp mediump int) +0:214 Condition +0:214 'gl_FrontFacing' (gl_FrontFacing bool) +0:214 true case +0:214 Constant: +0:214 1 (const int) +0:214 false case +0:214 Constant: +0:214 2 (const int) 0:? Linker Objects 0:? 'a' (global 3-element array of mediump int) 0:? 'uint' (global mediump int) @@ -670,4 +725,11 @@ ERROR: node is still EOpNull! 0:? 'f124' (global mediump float) 0:? 'sCube' (uniform lowp samplerCube) 0:? 's' (smooth in structure{global mediump float f}) +0:? 'fi1' (const mediump float) +0:? 3.000000 +0:? 'fi2' (const mediump float) +0:? 4.000000 +0:? 'fi3' (const mediump float) +0:? 5.000000 +0:? 'init1' (global mediump int) diff --git a/Test/baseResults/140.frag.out b/Test/baseResults/140.frag.out index ef3ebebafd9935c54a6ef8e7fd158d301fcb773a..d158f6ea6af01cfbd4d4697eaab2e40d349a6e89 100644 --- a/Test/baseResults/140.frag.out +++ b/Test/baseResults/140.frag.out @@ -6,8 +6,8 @@ ERROR: 0:24: 'location' : not supported for this version or the enabled extensio ERROR: 0:24: 'location qualifier on input' : not supported for this version or the enabled extensions ERROR: 0:26: 'location' : not supported for this version or the enabled extensions ERROR: 0:26: 'location qualifier on output' : not supported for this version or the enabled extensions -ERROR: 0:38: 'assign' : l-value required "v" (can't modify shader input) -ERROR: 0:38: 'out' : Non-L-value cannot be passed for 'out' or 'inout' parameters. +ERROR: 0:40: 'assign' : l-value required "v" (can't modify shader input) +ERROR: 0:40: 'out' : Non-L-value cannot be passed for 'out' or 'inout' parameters. ERROR: 8 compilation errors. No code generated. @@ -30,45 +30,75 @@ ERROR: node is still EOpNull! 0:22 'patch' (global float) 0:22 Constant: 0:22 3.100000 -0:36 Function Definition: foo( (global void) -0:36 Function Parameters: -0:38 Sequence -0:38 Sequence -0:38 move second child to first child (temp 2-component vector of float) -0:38 'r1' (temp 2-component vector of float) -0:38 modf (global 2-component vector of float) -0:38 vector swizzle (temp 2-component vector of float) -0:38 'v' (smooth in 4-component vector of float) -0:38 Sequence -0:38 Constant: -0:38 0 (const int) -0:38 Constant: -0:38 1 (const int) -0:38 vector swizzle (temp 2-component vector of float) -0:38 'v' (smooth in 4-component vector of float) -0:38 Sequence -0:38 Constant: -0:38 2 (const int) -0:38 Constant: -0:38 3 (const int) -0:39 Sequence -0:39 move second child to first child (temp 2-component vector of float) -0:39 'r2' (temp 2-component vector of float) -0:39 modf (global 2-component vector of float) -0:39 vector swizzle (temp 2-component vector of float) -0:39 'o' (out 4-component vector of float) -0:39 Sequence -0:39 Constant: -0:39 0 (const int) -0:39 Constant: -0:39 1 (const int) -0:39 vector swizzle (temp 2-component vector of float) -0:39 'o' (out 4-component vector of float) -0:39 Sequence -0:39 Constant: -0:39 2 (const int) -0:39 Constant: -0:39 3 (const int) +0:38 Function Definition: foo( (global void) +0:38 Function Parameters: +0:40 Sequence +0:40 Sequence +0:40 move second child to first child (temp 2-component vector of float) +0:40 'r1' (temp 2-component vector of float) +0:40 modf (global 2-component vector of float) +0:40 vector swizzle (temp 2-component vector of float) +0:40 'v' (smooth in 4-component vector of float) +0:40 Sequence +0:40 Constant: +0:40 0 (const int) +0:40 Constant: +0:40 1 (const int) +0:40 vector swizzle (temp 2-component vector of float) +0:40 'v' (smooth in 4-component vector of float) +0:40 Sequence +0:40 Constant: +0:40 2 (const int) +0:40 Constant: +0:40 3 (const int) +0:41 Sequence +0:41 move second child to first child (temp 2-component vector of float) +0:41 'r2' (temp 2-component vector of float) +0:41 modf (global 2-component vector of float) +0:41 vector swizzle (temp 2-component vector of float) +0:41 'o' (out 4-component vector of float) +0:41 Sequence +0:41 Constant: +0:41 0 (const int) +0:41 Constant: +0:41 1 (const int) +0:41 vector swizzle (temp 2-component vector of float) +0:41 'o' (out 4-component vector of float) +0:41 Sequence +0:41 Constant: +0:41 2 (const int) +0:41 Constant: +0:41 3 (const int) +0:42 move second child to first child (temp float) +0:42 direct index (temp float) +0:42 'o' (out 4-component vector of float) +0:42 Constant: +0:42 2 (const int) +0:42 Function Call: fooi( (global float) +0:47 Sequence +0:47 move second child to first child (temp float) +0:47 'i1' (global float) +0:47 Test condition and select (temp float) +0:47 Condition +0:47 'gl_FrontFacing' (gl_FrontFacing bool) +0:47 true case +0:47 Constant: +0:47 -2.000000 +0:47 false case +0:47 Constant: +0:47 2.000000 +0:48 Sequence +0:48 move second child to first child (temp float) +0:48 'i2' (global float) +0:48 Constant: +0:48 102.000000 +0:50 Function Definition: fooi( (global float) +0:50 Function Parameters: +0:52 Sequence +0:52 Branch: Return with expression +0:52 add (temp float) +0:52 'i1' (global float) +0:52 'i2' (global float) 0:? Linker Objects 0:? 'v' (smooth in 4-component vector of float) 0:? 'i' (smooth in 4-component vector of float) @@ -81,6 +111,8 @@ ERROR: node is still EOpNull! 0:? 'factorBad' (layout(location=3 ) out 4-component vector of float) 0:? 'factor' (layout(location=5 ) out 4-component vector of float) 0:? 'vl2' (layout(location=4 ) smooth in 4-component vector of float) +0:? 'i1' (global float) +0:? 'i2' (global float) Linked fragment stage: @@ -105,45 +137,75 @@ ERROR: node is still EOpNull! 0:22 'patch' (global float) 0:22 Constant: 0:22 3.100000 -0:36 Function Definition: foo( (global void) -0:36 Function Parameters: -0:38 Sequence -0:38 Sequence -0:38 move second child to first child (temp 2-component vector of float) -0:38 'r1' (temp 2-component vector of float) -0:38 modf (global 2-component vector of float) -0:38 vector swizzle (temp 2-component vector of float) -0:38 'v' (smooth in 4-component vector of float) -0:38 Sequence -0:38 Constant: -0:38 0 (const int) -0:38 Constant: -0:38 1 (const int) -0:38 vector swizzle (temp 2-component vector of float) -0:38 'v' (smooth in 4-component vector of float) -0:38 Sequence -0:38 Constant: -0:38 2 (const int) -0:38 Constant: -0:38 3 (const int) -0:39 Sequence -0:39 move second child to first child (temp 2-component vector of float) -0:39 'r2' (temp 2-component vector of float) -0:39 modf (global 2-component vector of float) -0:39 vector swizzle (temp 2-component vector of float) -0:39 'o' (out 4-component vector of float) -0:39 Sequence -0:39 Constant: -0:39 0 (const int) -0:39 Constant: -0:39 1 (const int) -0:39 vector swizzle (temp 2-component vector of float) -0:39 'o' (out 4-component vector of float) -0:39 Sequence -0:39 Constant: -0:39 2 (const int) -0:39 Constant: -0:39 3 (const int) +0:38 Function Definition: foo( (global void) +0:38 Function Parameters: +0:40 Sequence +0:40 Sequence +0:40 move second child to first child (temp 2-component vector of float) +0:40 'r1' (temp 2-component vector of float) +0:40 modf (global 2-component vector of float) +0:40 vector swizzle (temp 2-component vector of float) +0:40 'v' (smooth in 4-component vector of float) +0:40 Sequence +0:40 Constant: +0:40 0 (const int) +0:40 Constant: +0:40 1 (const int) +0:40 vector swizzle (temp 2-component vector of float) +0:40 'v' (smooth in 4-component vector of float) +0:40 Sequence +0:40 Constant: +0:40 2 (const int) +0:40 Constant: +0:40 3 (const int) +0:41 Sequence +0:41 move second child to first child (temp 2-component vector of float) +0:41 'r2' (temp 2-component vector of float) +0:41 modf (global 2-component vector of float) +0:41 vector swizzle (temp 2-component vector of float) +0:41 'o' (out 4-component vector of float) +0:41 Sequence +0:41 Constant: +0:41 0 (const int) +0:41 Constant: +0:41 1 (const int) +0:41 vector swizzle (temp 2-component vector of float) +0:41 'o' (out 4-component vector of float) +0:41 Sequence +0:41 Constant: +0:41 2 (const int) +0:41 Constant: +0:41 3 (const int) +0:42 move second child to first child (temp float) +0:42 direct index (temp float) +0:42 'o' (out 4-component vector of float) +0:42 Constant: +0:42 2 (const int) +0:42 Function Call: fooi( (global float) +0:47 Sequence +0:47 move second child to first child (temp float) +0:47 'i1' (global float) +0:47 Test condition and select (temp float) +0:47 Condition +0:47 'gl_FrontFacing' (gl_FrontFacing bool) +0:47 true case +0:47 Constant: +0:47 -2.000000 +0:47 false case +0:47 Constant: +0:47 2.000000 +0:48 Sequence +0:48 move second child to first child (temp float) +0:48 'i2' (global float) +0:48 Constant: +0:48 102.000000 +0:50 Function Definition: fooi( (global float) +0:50 Function Parameters: +0:52 Sequence +0:52 Branch: Return with expression +0:52 add (temp float) +0:52 'i1' (global float) +0:52 'i2' (global float) 0:? Linker Objects 0:? 'v' (smooth in 4-component vector of float) 0:? 'i' (smooth in 4-component vector of float) @@ -156,4 +218,6 @@ ERROR: node is still EOpNull! 0:? 'factorBad' (layout(location=3 ) out 4-component vector of float) 0:? 'factor' (layout(location=5 ) out 4-component vector of float) 0:? 'vl2' (layout(location=4 ) smooth in 4-component vector of float) +0:? 'i1' (global float) +0:? 'i2' (global float) diff --git a/Test/baseResults/lineContinuation.vert.out b/Test/baseResults/lineContinuation.vert.out index d6e514722fc27ea94de2e8bedaca82e72c62219f..06ede30d39adcdca41b13e08d03e0c3a008cf72b 100644 --- a/Test/baseResults/lineContinuation.vert.out +++ b/Test/baseResults/lineContinuation.vert.out @@ -42,25 +42,6 @@ ERROR: node is still EOpNull! 0:24 'a' (in highp 4-component vector of float) 0:25 Branch: Return with expression 0:25 'b' (temp highp 4-component vector of float) -0:42 Sequence -0:42 move second child to first child (temp highp int) -0:42 'a1' (global highp int) -0:42 Constant: -0:42 4 (const int) -0:43 Sequence -0:43 move second child to first child (temp highp int) -0:43 'a2' (global highp int) -0:43 Constant: -0:43 3 (const int) -0:44 Sequence -0:44 move second child to first child (temp highp int) -0:44 'a3' (global highp int) -0:44 Constant: -0:44 4 (const int) -0:45 Sequence -0:45 move second child to first child (temp highp int) -0:45 'a4' (global highp int) -0:45 'a2' (global highp int) 0:47 Sequence 0:47 move second child to first child (temp highp int) 0:47 'q1' (global highp int) @@ -81,15 +62,6 @@ ERROR: node is still EOpNull! 0:50 'q4' (global highp int) 0:50 Constant: 0:50 1 (const int) -0:65 Sequence -0:65 move second child to first child (temp highp int) -0:65 'abdece' (global highp int) -0:65 Constant: -0:65 10 (const int) -0:66 Sequence -0:66 move second child to first child (temp highp int) -0:66 'aoeuntaoehu' (global highp int) -0:66 'abdece' (global highp int) 0:74 Sequence 0:74 move second child to first child (temp highp float) 0:74 'funkyf' (global highp float) @@ -162,16 +134,22 @@ ERROR: node is still EOpNull! 0:? Linker Objects 0:? 'foo' (global highp float) 0:? 'goodDecl' (global highp int) -0:? 'a1' (global highp int) -0:? 'a2' (global highp int) -0:? 'a3' (global highp int) -0:? 'a4' (global highp int) +0:? 'a1' (const highp int) +0:? 4 (const int) +0:? 'a2' (const highp int) +0:? 3 (const int) +0:? 'a3' (const highp int) +0:? 4 (const int) +0:? 'a4' (const highp int) +0:? 3 (const int) 0:? 'q1' (global highp int) 0:? 'q2' (global highp int) 0:? 'q3' (global highp int) 0:? 'q4' (global highp int) -0:? 'abdece' (global highp int) -0:? 'aoeuntaoehu' (global highp int) +0:? 'abdece' (const highp int) +0:? 10 (const int) +0:? 'aoeuntaoehu' (const highp int) +0:? 10 (const int) 0:? 'funkyf' (global highp float) 0:? 'funkyh' (global highp int) 0:? 'funkyo' (global highp int) @@ -208,25 +186,6 @@ ERROR: node is still EOpNull! 0:24 'a' (in highp 4-component vector of float) 0:25 Branch: Return with expression 0:25 'b' (temp highp 4-component vector of float) -0:42 Sequence -0:42 move second child to first child (temp highp int) -0:42 'a1' (global highp int) -0:42 Constant: -0:42 4 (const int) -0:43 Sequence -0:43 move second child to first child (temp highp int) -0:43 'a2' (global highp int) -0:43 Constant: -0:43 3 (const int) -0:44 Sequence -0:44 move second child to first child (temp highp int) -0:44 'a3' (global highp int) -0:44 Constant: -0:44 4 (const int) -0:45 Sequence -0:45 move second child to first child (temp highp int) -0:45 'a4' (global highp int) -0:45 'a2' (global highp int) 0:47 Sequence 0:47 move second child to first child (temp highp int) 0:47 'q1' (global highp int) @@ -247,15 +206,6 @@ ERROR: node is still EOpNull! 0:50 'q4' (global highp int) 0:50 Constant: 0:50 1 (const int) -0:65 Sequence -0:65 move second child to first child (temp highp int) -0:65 'abdece' (global highp int) -0:65 Constant: -0:65 10 (const int) -0:66 Sequence -0:66 move second child to first child (temp highp int) -0:66 'aoeuntaoehu' (global highp int) -0:66 'abdece' (global highp int) 0:74 Sequence 0:74 move second child to first child (temp highp float) 0:74 'funkyf' (global highp float) @@ -328,16 +278,22 @@ ERROR: node is still EOpNull! 0:? Linker Objects 0:? 'foo' (global highp float) 0:? 'goodDecl' (global highp int) -0:? 'a1' (global highp int) -0:? 'a2' (global highp int) -0:? 'a3' (global highp int) -0:? 'a4' (global highp int) +0:? 'a1' (const highp int) +0:? 4 (const int) +0:? 'a2' (const highp int) +0:? 3 (const int) +0:? 'a3' (const highp int) +0:? 4 (const int) +0:? 'a4' (const highp int) +0:? 3 (const int) 0:? 'q1' (global highp int) 0:? 'q2' (global highp int) 0:? 'q3' (global highp int) 0:? 'q4' (global highp int) -0:? 'abdece' (global highp int) -0:? 'aoeuntaoehu' (global highp int) +0:? 'abdece' (const highp int) +0:? 10 (const int) +0:? 'aoeuntaoehu' (const highp int) +0:? 10 (const int) 0:? 'funkyf' (global highp float) 0:? 'funkyh' (global highp int) 0:? 'funkyo' (global highp int) diff --git a/Test/baseResults/lineContinuation100.vert.out b/Test/baseResults/lineContinuation100.vert.out index 54f7494d2db89d13f9828ee8718246819ec4d6a7..d0efb952d4a7ee9f23ebabb10585750e3e13d3a0 100644 --- a/Test/baseResults/lineContinuation100.vert.out +++ b/Test/baseResults/lineContinuation100.vert.out @@ -42,25 +42,6 @@ ERROR: node is still EOpNull! 0:24 'a' (in highp 4-component vector of float) 0:25 Branch: Return with expression 0:25 'b' (temp highp 4-component vector of float) -0:40 Sequence -0:40 move second child to first child (temp highp int) -0:40 'a1' (global highp int) -0:40 Constant: -0:40 4 (const int) -0:41 Sequence -0:41 move second child to first child (temp highp int) -0:41 'a2' (global highp int) -0:41 Constant: -0:41 3 (const int) -0:42 Sequence -0:42 move second child to first child (temp highp int) -0:42 'a3' (global highp int) -0:42 Constant: -0:42 4 (const int) -0:43 Sequence -0:43 move second child to first child (temp highp int) -0:43 'a4' (global highp int) -0:43 'a2' (global highp int) 0:45 Sequence 0:45 move second child to first child (temp highp int) 0:45 'q1' (global highp int) @@ -83,10 +64,14 @@ ERROR: node is still EOpNull! 0:48 1 (const int) 0:? Linker Objects 0:? 'foo' (global highp float) -0:? 'a1' (global highp int) -0:? 'a2' (global highp int) -0:? 'a3' (global highp int) -0:? 'a4' (global highp int) +0:? 'a1' (const highp int) +0:? 4 (const int) +0:? 'a2' (const highp int) +0:? 3 (const int) +0:? 'a3' (const highp int) +0:? 4 (const int) +0:? 'a4' (const highp int) +0:? 3 (const int) 0:? 'q1' (global highp int) 0:? 'q2' (global highp int) 0:? 'q3' (global highp int) @@ -115,25 +100,6 @@ ERROR: node is still EOpNull! 0:24 'a' (in highp 4-component vector of float) 0:25 Branch: Return with expression 0:25 'b' (temp highp 4-component vector of float) -0:40 Sequence -0:40 move second child to first child (temp highp int) -0:40 'a1' (global highp int) -0:40 Constant: -0:40 4 (const int) -0:41 Sequence -0:41 move second child to first child (temp highp int) -0:41 'a2' (global highp int) -0:41 Constant: -0:41 3 (const int) -0:42 Sequence -0:42 move second child to first child (temp highp int) -0:42 'a3' (global highp int) -0:42 Constant: -0:42 4 (const int) -0:43 Sequence -0:43 move second child to first child (temp highp int) -0:43 'a4' (global highp int) -0:43 'a2' (global highp int) 0:45 Sequence 0:45 move second child to first child (temp highp int) 0:45 'q1' (global highp int) @@ -156,10 +122,14 @@ ERROR: node is still EOpNull! 0:48 1 (const int) 0:? Linker Objects 0:? 'foo' (global highp float) -0:? 'a1' (global highp int) -0:? 'a2' (global highp int) -0:? 'a3' (global highp int) -0:? 'a4' (global highp int) +0:? 'a1' (const highp int) +0:? 4 (const int) +0:? 'a2' (const highp int) +0:? 3 (const int) +0:? 'a3' (const highp int) +0:? 4 (const int) +0:? 'a4' (const highp int) +0:? 3 (const int) 0:? 'q1' (global highp int) 0:? 'q2' (global highp int) 0:? 'q3' (global highp int) diff --git a/Test/lineContinuation.vert b/Test/lineContinuation.vert index f83212e2a179cf83eae000a0d4e461087bd916cc..471f3a34227fb6006ba83d4f440a543c3e9d9b97 100644 --- a/Test/lineContinuation.vert +++ b/Test/lineContinuation.vert @@ -39,10 +39,10 @@ FOO #define C int q3 = $ 1 #define D int q4 = @ 1 -int a1 = \ 4; // ERROR -int a2 = @ 3; // ERROR -int a3 = $4; // ERROR -int a4 = a2\; // ERROR +const highp int a1 = \ 4; // ERROR +const highp int a2 = @ 3; // ERROR +const highp int a3 = $4; // ERROR +const highp int a4 = a2\; // ERROR A; B; @@ -62,8 +62,8 @@ D; // anoetuh nonaetu \\\\\\ still in comment -int abdece = 10; -int aoeuntaoehu = abd\ +const int abdece = 10; +const int aoeuntaoehu = abd\ \ \ \ diff --git a/Test/lineContinuation100.vert b/Test/lineContinuation100.vert index 32b1946824babebe0bfb7f7be6bbfe28009fe017..e632023cc540a97035b11b30814ab1ac988eb547 100644 --- a/Test/lineContinuation100.vert +++ b/Test/lineContinuation100.vert @@ -37,10 +37,10 @@ vec4 foo2(vec4 a) #define C int q3 = $ 1 #define D int q4 = @ 1 -int a1 = \ 4; // ERROR -int a2 = @ 3; // ERROR -int a3 = $4; // ERROR -int a4 = a2\; // ERROR +const highp int a1 = \ 4; // ERROR +const highp int a2 = @ 3; // ERROR +const highp int a3 = $4; // ERROR +const highp int a4 = a2\; // ERROR A; B; diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 43911d6292df76e41d56bb7ada1bcf31b3f53d0b..8b1723caef0bd3f813fe94da7cc3078948fd1bc9 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -4154,6 +4154,15 @@ TIntermNode* TParseContext::executeInitializer(TSourceLoc loc, TString& identifi variable->getWritableType().getQualifier().storage = EvqConstReadOnly; qualifier = EvqConstReadOnly; } + } else { + // Non-const global variables in ES need a const initializer. + // + // "In declarations of global variables with no storage qualifier or with a const + // qualifier any initializer must be a constant expression." + if (symbolTable.atGlobalLevel() && initializer->getType().getQualifier().storage != EvqConst) { + const char* initFeature = "non-constant global initializer"; + requireProfile(loc, ~EEsProfile, initFeature); + } } if (qualifier == EvqConst || qualifier == EvqUniform) {