Array-sizing bug fix: multiple array initializers of different size in the same decla...
authorJohn Kessenich <cepheus@frii.com>
Sat, 28 Nov 2015 19:52:29 +0000 (12:52 -0700)
committerJohn Kessenich <cepheus@frii.com>
Sat, 28 Nov 2015 19:52:29 +0000 (12:52 -0700)
Handles the case of
    float[] x = float[] (1.0, 2.0, 3.0),
            y = float[] (1.0, 2.0, 3.0, 4.0);
where a shallow copy of the type arrayness from the left-most float[]
was getting used twice.

Test/300.vert
Test/baseResults/300.vert.out
glslang/Include/Types.h
glslang/Include/revision.h
glslang/MachineIndependent/ParseHelper.cpp

index 6270c1d..83b9bb1 100644 (file)
@@ -174,3 +174,14 @@ layout(std430) uniform B430 { int a; } B430i;     // ERROR
 struct SNA {
     int a[];             // ERROR
 };
+
+void fooDeeparray()
+{
+    float[] x = float[] (1.0, 2.0, 3.0),
+            y = float[] (1.0, 2.0, 3.0, 4.0);
+    float xp[3], yp[4];
+    xp = x;
+    yp = y;
+    xp = y; // ERROR, wrong size
+    yp = x; // ERROR, wrong size
+}
index d3d7cba..6f3fdad 100644 (file)
@@ -41,7 +41,9 @@ ERROR: 0:170: 'Bfoo' : cannot add storage, auxiliary, memory, interpolation, lay
 ERROR: 0:172: 'std430' : not supported for this version or the enabled extensions \r
 ERROR: 0:172: 'std430 on a uniform block' : not supported with this profile: es\r
 ERROR: 0:175: '' : array size required \r
-ERROR: 42 compilation errors.  No code generated.\r
+ERROR: 0:185: 'assign' :  cannot convert from 'temp 4-element array of highp float' to 'temp 3-element array of highp float'\r
+ERROR: 0:186: 'assign' :  cannot convert from 'temp 3-element array of highp float' to 'temp 4-element array of highp float'\r
+ERROR: 44 compilation errors.  No code generated.\r
 \r
 \r
 Shader version: 300\r
@@ -262,6 +264,31 @@ ERROR: node is still EOpNull!
 0:158      Branch: Return with expression\r
 0:158        Constant:\r
 0:158          2 (const int)\r
+0:178  Function Definition: fooDeeparray( (global void)\r
+0:178    Function Parameters: \r
+0:181    Sequence\r
+0:181      Sequence\r
+0:180        move second child to first child (temp 3-element array of highp float)\r
+0:180          'x' (temp 3-element array of highp float)\r
+0:180          Constant:\r
+0:180            1.000000\r
+0:180            2.000000\r
+0:180            3.000000\r
+0:181        move second child to first child (temp 4-element array of highp float)\r
+0:181          'y' (temp 4-element array of highp float)\r
+0:181          Constant:\r
+0:181            1.000000\r
+0:181            2.000000\r
+0:181            3.000000\r
+0:181            4.000000\r
+0:183      move second child to first child (temp 3-element array of highp float)\r
+0:183        'xp' (temp 3-element array of highp float)\r
+0:183        'x' (temp 3-element array of highp float)\r
+0:184      move second child to first child (temp 4-element array of highp float)\r
+0:184        'yp' (temp 4-element array of highp float)\r
+0:184        'y' (temp 4-element array of highp float)\r
+0:185      'xp' (temp 3-element array of highp float)\r
+0:186      'yp' (temp 4-element array of highp float)\r
 0:?   Linker Objects\r
 0:?     'm43' (uniform highp 4X3 matrix of float)\r
 0:?     'm33' (uniform highp 3X3 matrix of float)\r
@@ -521,6 +548,31 @@ ERROR: node is still EOpNull!
 0:158      Branch: Return with expression\r
 0:158        Constant:\r
 0:158          2 (const int)\r
+0:178  Function Definition: fooDeeparray( (global void)\r
+0:178    Function Parameters: \r
+0:181    Sequence\r
+0:181      Sequence\r
+0:180        move second child to first child (temp 3-element array of highp float)\r
+0:180          'x' (temp 3-element array of highp float)\r
+0:180          Constant:\r
+0:180            1.000000\r
+0:180            2.000000\r
+0:180            3.000000\r
+0:181        move second child to first child (temp 4-element array of highp float)\r
+0:181          'y' (temp 4-element array of highp float)\r
+0:181          Constant:\r
+0:181            1.000000\r
+0:181            2.000000\r
+0:181            3.000000\r
+0:181            4.000000\r
+0:183      move second child to first child (temp 3-element array of highp float)\r
+0:183        'xp' (temp 3-element array of highp float)\r
+0:183        'x' (temp 3-element array of highp float)\r
+0:184      move second child to first child (temp 4-element array of highp float)\r
+0:184        'yp' (temp 4-element array of highp float)\r
+0:184        'y' (temp 4-element array of highp float)\r
+0:185      'xp' (temp 3-element array of highp float)\r
+0:186      'yp' (temp 4-element array of highp float)\r
 0:?   Linker Objects\r
 0:?     'm43' (uniform highp 4X3 matrix of float)\r
 0:?     'm33' (uniform highp 3X3 matrix of float)\r
index e943369..ec17943 100644 (file)
@@ -930,7 +930,7 @@ public:
                                 qualifier.precision = p;
                                 assert(p >= 0 && p <= EpqHigh);
                             }
-    // for turning a TPublicType into a TType
+    // for turning a TPublicType into a TType, using a shallow copy
     explicit TType(const TPublicType& p) :
                             basicType(p.basicType), vectorSize(p.vectorSize), matrixCols(p.matrixCols), matrixRows(p.matrixRows), arraySizes(p.arraySizes),
                             structure(nullptr), fieldName(nullptr), typeName(nullptr)
index 0a7786d..7f6f677 100644 (file)
@@ -2,5 +2,5 @@
 // For the version, it uses the latest git tag followed by the number of commits.
 // For the date, it uses the current date (when then script is run).
 
-#define GLSLANG_REVISION "SPIRV99.798"
-#define GLSLANG_DATE "16-Nov-2015"
+#define GLSLANG_REVISION "SPIRV99.807"
+#define GLSLANG_DATE "28-Nov-2015"
index 96e18f6..6d50cbe 100644 (file)
@@ -4447,7 +4447,13 @@ void TParseContext::declareTypeDefaults(const TSourceLoc& loc, const TPublicType
 //
 TIntermNode* TParseContext::declareVariable(const TSourceLoc& loc, TString& identifier, const TPublicType& publicType, TArraySizes* arraySizes, TIntermTyped* initializer)
 {
-    TType type(publicType);
+    TType type(publicType);  // shallow copy; 'type' shares the arrayness and structure definition with 'publicType'
+    if (type.isImplicitlySizedArray()) {
+        // Because "int[] a = int[2](...), b = int[3](...)" makes two arrays a and b
+        // of different sizes, for this case sharing the shallow copy of arrayness
+        // with the publicType oversubscribes it, so get a deep copy of the arrayness.
+        type.newArraySizes(*publicType.arraySizes);
+    }
 
     if (voidErrorCheck(loc, identifier, type.getBasicType()))
         return nullptr;