HLSL: Fix #1203: Declare anonymous members for cbuffer with no ';'

The grammar for no semicolon and no object name for cbuffer/tbuffer
was correct, but the production still skipped the anonymous declarations
if an identifier followed.
This commit is contained in:
John Kessenich
2018-01-02 11:27:54 -07:00
parent fd1e8a78a8
commit 132cf53737
4 changed files with 271 additions and 207 deletions

View File

@@ -376,7 +376,7 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& nodeList)
bool forbidDeclarators = (peekTokenClass(EHTokCBuffer) || peekTokenClass(EHTokTBuffer));
// fully_specified_type
if (! acceptFullySpecifiedType(declaredType, nodeList, declarator.attributes))
if (! acceptFullySpecifiedType(declaredType, nodeList, declarator.attributes, forbidDeclarators))
return false;
// cbuffer and tbuffer end with the closing '}'.
@@ -583,7 +583,7 @@ bool HlslGrammar::acceptFullySpecifiedType(TType& type, const TAttributeMap& att
TIntermNode* nodeList = nullptr;
return acceptFullySpecifiedType(type, nodeList, attributes);
}
bool HlslGrammar::acceptFullySpecifiedType(TType& type, TIntermNode*& nodeList, const TAttributeMap& attributes)
bool HlslGrammar::acceptFullySpecifiedType(TType& type, TIntermNode*& nodeList, const TAttributeMap& attributes, bool forbidDeclarators)
{
// type_qualifier
TQualifier qualifier;
@@ -611,7 +611,7 @@ bool HlslGrammar::acceptFullySpecifiedType(TType& type, TIntermNode*& nodeList,
parseContext.transferTypeAttributes(attributes, type);
// further, it can create an anonymous instance of the block
if (peek() != EHTokIdentifier)
if (forbidDeclarators || peek() != EHTokIdentifier)
parseContext.declareBlock(loc, type);
} else {
// Some qualifiers are set when parsing the type. Merge those with