Commit 39282e1f by Olli Etuaho

Disallow length being called on expressions with side effects

ESSL 3.00 definition of expressions does not include calling length on anything other than array names, so enforce this restriction in the parser. TEST=WebGL 2 conformance tests BUG=angleproject:972 Change-Id: I893d3c468ff21cb419b3239738f2a41834298cf2 Reviewed-on: https://chromium-review.googlesource.com/266992Reviewed-by: 's avatarOlli Etuaho <oetuaho@nvidia.com> Tested-by: 's avatarOlli Etuaho <oetuaho@nvidia.com>
parent 96e67388
...@@ -3168,12 +3168,17 @@ TIntermTyped *TParseContext::addFunctionCallOrMethod(TFunction *fnCall, TIntermN ...@@ -3168,12 +3168,17 @@ TIntermTyped *TParseContext::addFunctionCallOrMethod(TFunction *fnCall, TIntermN
else else
{ {
arraySize = typedThis->getArraySize(); arraySize = typedThis->getArraySize();
if (typedThis->hasSideEffects()) if (typedThis->getAsSymbolNode() == nullptr)
{ {
// This code path can be hit with an expression like this: // This code path can be hit with expressions like these:
// (a = b).length() // (a = b).length()
// where a and b are both arrays. // (func()).length()
UNIMPLEMENTED(); // (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); unionArray->setIConst(arraySize);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment