Fix parsing structure definitions in place of constructors
The shader parser used to accept structure definitions in place of
constructors, which is invalid GLSL. This patch fixes that.
BUG=angleproject:939
TEST=angle_unittests
Change-Id: Ibcf502160e91c19e693e9427b548a399d83e2a71
Reviewed-on: https://chromium-review.googlesource.com/312032
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Tested-by: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/ParseContext.cpp b/src/compiler/translator/ParseContext.cpp
index 8486ac0..9676016 100644
--- a/src/compiler/translator/ParseContext.cpp
+++ b/src/compiler/translator/ParseContext.cpp
@@ -2093,6 +2093,13 @@
TFunction *TParseContext::addConstructorFunc(const TPublicType &publicTypeIn)
{
TPublicType publicType = publicTypeIn;
+ if (publicType.isStructSpecifier)
+ {
+ error(publicType.line, "constructor can't be a structure definition",
+ getBasicString(publicType.type));
+ recover();
+ }
+
TOperator op = EOpNull;
if (publicType.userDef)
{
@@ -3281,6 +3288,7 @@
TPublicType publicType;
publicType.setBasic(EbtStruct, EvqTemporary, structLine);
publicType.userDef = structureType;
+ publicType.isStructSpecifier = true;
exitStructDeclaration();
return publicType;