Fix, and add missing tests for, error catching for applying swizzles to arrays.
authorJohn Kessenich <cepheus@frii.com>
Tue, 27 May 2014 01:34:38 +0000 (01:34 +0000)
committerJohn Kessenich <cepheus@frii.com>
Tue, 27 May 2014 01:34:38 +0000 (01:34 +0000)
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@26858 e7fa87d3-cd2b-0410-9028-fcbf551c1848

Test/100.frag
Test/baseResults/100.frag.out
Test/baseResults/120.vert.out
glslang/MachineIndependent/ParseHelper.cpp

index 28b0ec4..672e969 100644 (file)
@@ -178,4 +178,20 @@ int agggf(float f);  // ERROR, second prototype
 \r
 varying struct SSS { float f; } s; // ERROR\r
 \r
+int vf(void);\r
+int vf2();\r
+int vf3(void v);      // ERROR\r
+int vf4(int, void);   // ERROR\r
+int vf5(int, void v); // ERROR\r
+\r
+void badswizzle()\r
+{\r
+    vec3 a[5];\r
+    a.y;        // ERROR, no array swizzle\r
+    a.zy;       // ERROR, no array swizzle\r
+    a.nothing;  // ERROR\r
+    a.length(); // ERROR, not this version\r
+    a.method(); // ERROR\r
+}\r
+\r
 uniform samplerExternalOES badExt;  // syntax ERROR\r
index bf72cd8..c3a0402 100644 (file)
@@ -67,8 +67,18 @@ ERROR: 0:167: 'highp' : overloaded functions must have the same parameter precis
 ERROR: 0:170: 'multiple prototypes for same function' : not supported for this version or the enabled extensions \r
 ERROR: 0:177: 'multiple prototypes for same function' : not supported for this version or the enabled extensions \r
 ERROR: 0:179: 'fragment-shader struct input' : not supported for this version or the enabled extensions \r
-ERROR: 0:181: '' :  syntax error\r
-ERROR: 62 compilation errors.  No code generated.\r
+ERROR: 0:183: 'v' : illegal use of type 'void' \r
+ERROR: 0:184: 'void' : cannot be an argument type except for '(void)' \r
+ERROR: 0:185: 'v' : illegal use of type 'void' \r
+ERROR: 0:185: 'void' : cannot be an argument type except for '(void)' \r
+ERROR: 0:190: '.' : cannot apply to an array: y\r
+ERROR: 0:191: '.' : cannot apply to an array: zy\r
+ERROR: 0:192: '.' : cannot apply to an array: nothing\r
+ERROR: 0:193: '.length' : not supported for this version or the enabled extensions \r
+ERROR: 0:194: '.' : cannot apply to an array: method\r
+ERROR: 0:194: 'a' : can't use function syntax on variable \r
+ERROR: 0:197: '' :  syntax error\r
+ERROR: 72 compilation errors.  No code generated.\r
 \r
 \r
 Shader version: 100\r
@@ -326,6 +336,16 @@ ERROR: node is still EOpNull!
 0:175      Branch: Return with expression\r
 0:175        Constant:\r
 0:175          2 (const int)\r
+0:187  Function Definition: badswizzle( (void)\r
+0:187    Function Parameters: \r
+0:?     Sequence\r
+0:190      'a' (5-element array of mediump 3-component vector of float)\r
+0:191      'a' (5-element array of mediump 3-component vector of float)\r
+0:192      'a' (5-element array of mediump 3-component vector of float)\r
+0:193      Constant:\r
+0:193        5 (const int)\r
+0:194      Constant:\r
+0:194        0.000000\r
 0:?   Linker Objects\r
 0:?     'a' (3-element array of mediump int)\r
 0:?     'uint' (mediump int)\r
@@ -610,6 +630,16 @@ ERROR: node is still EOpNull!
 0:175      Branch: Return with expression\r
 0:175        Constant:\r
 0:175          2 (const int)\r
+0:187  Function Definition: badswizzle( (void)\r
+0:187    Function Parameters: \r
+0:?     Sequence\r
+0:190      'a' (5-element array of mediump 3-component vector of float)\r
+0:191      'a' (5-element array of mediump 3-component vector of float)\r
+0:192      'a' (5-element array of mediump 3-component vector of float)\r
+0:193      Constant:\r
+0:193        5 (const int)\r
+0:194      Constant:\r
+0:194        0.000000\r
 0:?   Linker Objects\r
 0:?     'a' (3-element array of mediump int)\r
 0:?     'uint' (mediump int)\r
index 1111c07..d5508d4 100644 (file)
@@ -11,9 +11,9 @@ ERROR: 0:21: 'assign' :  l-value required (can't modify a const)
 ERROR: 0:28: 'length' :  array must be declared with a size before using this method\r
 ERROR: 0:31: 'length' : incomplete method syntax \r
 ERROR: 0:32: 'length' : method does not accept any arguments \r
-ERROR: 0:33: 'flizbit' : does not apply to this type: 7-element array of float\r
+ERROR: 0:33: '.' : cannot apply to an array: flizbit\r
 ERROR: 0:33: '=' :  cannot convert from '7-element array of float' to 'int'\r
-ERROR: 0:34: 'flizbit' : does not apply to this type: 7-element array of float\r
+ERROR: 0:34: '.' : cannot apply to an array: flizbit\r
 ERROR: 0:34: 'f' : can't use function syntax on variable \r
 ERROR: 0:34: 'a4' : redefinition \r
 ERROR: 0:35: 'arrays of arrays' : not supported with this profile: none\r
index 82e9855..d37e879 100644 (file)
@@ -697,6 +697,17 @@ TIntermTyped* TParseContext::handleDotDereference(TSourceLoc loc, TIntermTyped*
         return intermediate.addMethod(base, TType(EbtInt), &field, loc);
     }
 
+    // It's not .length() if we get to here.
+
+    if (base->isArray()) {
+        error(loc, "cannot apply to an array:", ".", field.c_str());
+
+        return base;
+    }
+
+    // It's neither an array nor .length() if we get here,
+    // leaving swizzles and struct/block dereferences.
+
     TIntermTyped* result = base;
     if (base->isVector() || base->isScalar()) {
         if (base->isScalar()) {