Commit 0bd18dfb by Jamie Madill Committed by Shannon Woods

Enforce shader input and output variables with a specified location to be single declarations.

This prevents using in and out qualifiers on multiply declared vertex inputs and fragment outputs. TRAC #23311 Signed-off-by: Nicolas Capens Signed-off-by: Shannon Woods Authored-by: Jamie Madill
parent 502d66f6
...@@ -649,6 +649,17 @@ bool TParseContext::structQualifierErrorCheck(int line, const TPublicType& pType ...@@ -649,6 +649,17 @@ bool TParseContext::structQualifierErrorCheck(int line, const TPublicType& pType
return false; return false;
} }
bool TParseContext::locationDeclaratorListCheck(int line, const TPublicType &pType)
{
if (pType.layoutQualifier.location != -1)
{
error(line, "location must only be specified for a single input or output variable", "location");
return true;
}
return false;
}
bool TParseContext::parameterSamplerErrorCheck(int line, TQualifier qualifier, const TType& type) bool TParseContext::parameterSamplerErrorCheck(int line, TQualifier qualifier, const TType& type)
{ {
if ((qualifier == EvqOut || qualifier == EvqInOut) && if ((qualifier == EvqOut || qualifier == EvqInOut) &&
...@@ -1322,6 +1333,9 @@ TIntermAggregate* TParseContext::parseDeclarator(TPublicType &publicType, TInter ...@@ -1322,6 +1333,9 @@ TIntermAggregate* TParseContext::parseDeclarator(TPublicType &publicType, TInter
if (structQualifierErrorCheck(identifierLocation, publicType)) if (structQualifierErrorCheck(identifierLocation, publicType))
recover(); recover();
if (locationDeclaratorListCheck(identifierLocation, publicType))
recover();
if (nonInitConstErrorCheck(identifierLocation, identifier, publicType, false)) if (nonInitConstErrorCheck(identifierLocation, identifier, publicType, false))
recover(); recover();
...@@ -1339,6 +1353,9 @@ TIntermAggregate* TParseContext::parseArrayDeclarator(TPublicType &publicType, T ...@@ -1339,6 +1353,9 @@ TIntermAggregate* TParseContext::parseArrayDeclarator(TPublicType &publicType, T
if (structQualifierErrorCheck(identifierLocation, publicType)) if (structQualifierErrorCheck(identifierLocation, publicType))
recover(); recover();
if (locationDeclaratorListCheck(identifierLocation, publicType))
recover();
if (nonInitConstErrorCheck(identifierLocation, identifier, publicType, true)) if (nonInitConstErrorCheck(identifierLocation, identifier, publicType, true))
recover(); recover();
...@@ -1378,6 +1395,9 @@ TIntermAggregate* TParseContext::parseInitDeclarator(TPublicType &publicType, TI ...@@ -1378,6 +1395,9 @@ TIntermAggregate* TParseContext::parseInitDeclarator(TPublicType &publicType, TI
if (structQualifierErrorCheck(identifierLocation, publicType)) if (structQualifierErrorCheck(identifierLocation, publicType))
recover(); recover();
if (locationDeclaratorListCheck(identifierLocation, publicType))
recover();
TIntermNode* intermNode; TIntermNode* intermNode;
if (!executeInitializer(identifierLocation, identifier, publicType, initializer, intermNode)) if (!executeInitializer(identifierLocation, identifier, publicType, initializer, intermNode))
{ {
......
...@@ -95,6 +95,7 @@ struct TParseContext { ...@@ -95,6 +95,7 @@ struct TParseContext {
bool boolErrorCheck(int, const TPublicType&); bool boolErrorCheck(int, const TPublicType&);
bool samplerErrorCheck(int line, const TPublicType& pType, const char* reason); bool samplerErrorCheck(int line, const TPublicType& pType, const char* reason);
bool structQualifierErrorCheck(int line, const TPublicType& pType); bool structQualifierErrorCheck(int line, const TPublicType& pType);
bool locationDeclaratorListCheck(int line, const TPublicType &pType);
bool parameterSamplerErrorCheck(int line, TQualifier qualifier, const TType& type); bool parameterSamplerErrorCheck(int line, TQualifier qualifier, const TType& type);
bool nonInitConstErrorCheck(int line, const TString& identifier, TPublicType& type, bool array); bool nonInitConstErrorCheck(int line, const TString& identifier, TPublicType& type, bool array);
bool nonInitErrorCheck(int line, const TString& identifier, const TPublicType& type, TVariable*& variable); bool nonInitErrorCheck(int line, const TString& identifier, const TPublicType& type, TVariable*& variable);
......
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