Allow length() method on any array expression.
GLSL ES 3.00 spec says that length is only allowed on "array names",
but according to
https://bugs.chromium.org/p/angleproject/issues/detail?id=2142 that
was not intended to be interpreted strictly and it has been clarified
in GLSL ES 3.20.
Change-Id: Id8944346908e1c122230fd2f94c9a26cf389498b
Reviewed-on: https://swiftshader-review.googlesource.com/15550
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/OpenGL/compiler/ParseHelper.cpp b/src/OpenGL/compiler/ParseHelper.cpp
index 01a01b3..d057364 100644
--- a/src/OpenGL/compiler/ParseHelper.cpp
+++ b/src/OpenGL/compiler/ParseHelper.cpp
@@ -3536,18 +3536,6 @@
else
{
arraySize = typedThis->getArraySize();
- if(typedThis->getAsSymbolNode() == nullptr)
- {
- // This code path can be hit with expressions like these:
- // (a = b).length()
- // (func()).length()
- // (int[3](0, 1, 2)).length()
- // ESSL 3.00 section 5.9 defines expressions so that this is not actually a valid expression.
- // It allows "An array name with the length method applied" in contrast to GLSL 4.4 spec section 5.9
- // which allows "An array, vector or matrix expression with the length method applied".
- error(loc, "length can only be called on array names, not on array expressions", "length");
- recover();
- }
}
unionArray->setIConst(arraySize);
callNode = intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConstExpr), loc);