Check that implicitly sized array constructors have arguments
Array size must be greater than zero according to the ESSL 3.00.6
spec.
BUG=angleproject:1602
TEST=angle_unittests
Change-Id: I1fa54b143bc821583822cbc5139464cdd058b6c1
Reviewed-on: https://chromium-review.googlesource.com/407257
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/compiler/translator/ParseContext.cpp b/src/compiler/translator/ParseContext.cpp
index 45fe4a5..344c92f 100644
--- a/src/compiler/translator/ParseContext.cpp
+++ b/src/compiler/translator/ParseContext.cpp
@@ -2595,6 +2595,12 @@
TType type = fnCall->getReturnType();
if (type.isUnsizedArray())
{
+ if (fnCall->getParamCount() == 0)
+ {
+ error(line, "implicitly sized array constructor must have at least one argument", "[]");
+ type.setArraySize(1u);
+ return TIntermTyped::CreateZero(type);
+ }
type.setArraySize(static_cast<unsigned int>(fnCall->getParamCount()));
}
bool constType = true;