Clean up parsing function headers
Move function header parsing code to ParseContext instead of having
it in the grammar file. This commit is pure refactoring. This code
needs to be changed later to detect returning arrays containing
structs.
This commit also disables clang format for glslang.cpp generated by
bison.
TEST=angle_unittests
BUG=angleproject:1015
Change-Id: If60848ca32da6b98ea8bcd95bba8c3f831634b51
Reviewed-on: https://chromium-review.googlesource.com/352480
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/ParseContext.cpp b/src/compiler/translator/ParseContext.cpp
index 7f67daa..db9aa05 100644
--- a/src/compiler/translator/ParseContext.cpp
+++ b/src/compiler/translator/ParseContext.cpp
@@ -2178,6 +2178,31 @@
return function;
}
+TFunction *TParseContext::parseFunctionHeader(const TPublicType &type,
+ const TString *name,
+ const TSourceLoc &location)
+{
+ if (type.qualifier != EvqGlobal && type.qualifier != EvqTemporary)
+ {
+ error(location, "no qualifiers allowed for function return",
+ getQualifierString(type.qualifier));
+ recover();
+ }
+ if (!type.layoutQualifier.isEmpty())
+ {
+ error(location, "no qualifiers allowed for function return", "layout");
+ recover();
+ }
+ // make sure a sampler is not involved as well...
+ if (samplerErrorCheck(location, type, "samplers can't be function return values"))
+ {
+ recover();
+ }
+
+ // Add the function as a prototype after parsing it (we do not support recursion)
+ return new TFunction(name, new TType(type));
+}
+
TFunction *TParseContext::addConstructorFunc(const TPublicType &publicTypeIn)
{
TPublicType publicType = publicTypeIn;