Require size for empty array declarations
Passing dEQP tests requires this check, which seems to be a valid interpretation
of ESSL3 spec section 4.1.9.
BUG=angleproject:941
TEST=dEQP-GLES3.functional.shaders.arrays.invalid.*
Change-Id: Iae88e6bb8e4ec784a2f1c8a94554e1e5c5e3ee85
Reviewed-on: https://chromium-review.googlesource.com/267430
Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/ParseContext.cpp b/src/compiler/translator/ParseContext.cpp
index cd7ffc4..b9907ba 100644
--- a/src/compiler/translator/ParseContext.cpp
+++ b/src/compiler/translator/ParseContext.cpp
@@ -1257,9 +1257,20 @@
{
TIntermSymbol *symbol = intermediate.addSymbol(0, identifier, TType(publicType), identifierOrTypeLocation);
- mDeferredSingleDeclarationErrorCheck = (identifier == "");
+ bool emptyDeclaration = (identifier == "");
- if (!mDeferredSingleDeclarationErrorCheck)
+ mDeferredSingleDeclarationErrorCheck = emptyDeclaration;
+
+ if (emptyDeclaration)
+ {
+ if (publicType.isUnsizedArray())
+ {
+ // ESSL3 spec section 4.1.9: Array declaration which leaves the size unspecified is an error.
+ // It is assumed that this applies to empty declarations as well.
+ error(identifierOrTypeLocation, "empty array declaration needs to specify a size", identifier.c_str());
+ }
+ }
+ else
{
if (singleDeclarationErrorCheck(publicType, identifierOrTypeLocation))
recover();