Array-sizing bug fix: multiple array initializers of different size in the same declaration.

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.
This commit is contained in:
John Kessenich 2015-11-28 12:52:29 -07:00
parent dad6408542
commit 989df85dcd
5 changed files with 74 additions and 5 deletions

View 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)

View 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"

View 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;