Commit 132cf537 by John Kessenich

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.
parent fd1e8a78
...@@ -31,7 +31,17 @@ float foo() // float looks like identifier, but can't be part of tbuffer ...@@ -31,7 +31,17 @@ float foo() // float looks like identifier, but can't be part of tbuffer
return 1.0; return 1.0;
} }
float4 PixelShaderFunction(float4 input : SV_POSITION) : SV_TARGET0 struct id {
float4 a;
};
cbuffer cbufName2 {
float4 v24;
}
id PixelShaderFunction(float4 input : SV_POSITION) : SV_TARGET0 // id looks like id for cbuffer name, but can't be
{ {
return (input + v1 + v2 + v3 + v4) * foo(); id ret;
ret.a = v24 + (input + v1 + v2 + v3 + v4) * foo();
return ret;
} }
...@@ -376,7 +376,7 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& nodeList) ...@@ -376,7 +376,7 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& nodeList)
bool forbidDeclarators = (peekTokenClass(EHTokCBuffer) || peekTokenClass(EHTokTBuffer)); bool forbidDeclarators = (peekTokenClass(EHTokCBuffer) || peekTokenClass(EHTokTBuffer));
// fully_specified_type // fully_specified_type
if (! acceptFullySpecifiedType(declaredType, nodeList, declarator.attributes)) if (! acceptFullySpecifiedType(declaredType, nodeList, declarator.attributes, forbidDeclarators))
return false; return false;
// cbuffer and tbuffer end with the closing '}'. // cbuffer and tbuffer end with the closing '}'.
...@@ -583,7 +583,7 @@ bool HlslGrammar::acceptFullySpecifiedType(TType& type, const TAttributeMap& att ...@@ -583,7 +583,7 @@ bool HlslGrammar::acceptFullySpecifiedType(TType& type, const TAttributeMap& att
TIntermNode* nodeList = nullptr; TIntermNode* nodeList = nullptr;
return acceptFullySpecifiedType(type, nodeList, attributes); 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 // type_qualifier
TQualifier qualifier; TQualifier qualifier;
...@@ -611,7 +611,7 @@ bool HlslGrammar::acceptFullySpecifiedType(TType& type, TIntermNode*& nodeList, ...@@ -611,7 +611,7 @@ bool HlslGrammar::acceptFullySpecifiedType(TType& type, TIntermNode*& nodeList,
parseContext.transferTypeAttributes(attributes, type); parseContext.transferTypeAttributes(attributes, type);
// further, it can create an anonymous instance of the block // further, it can create an anonymous instance of the block
if (peek() != EHTokIdentifier) if (forbidDeclarators || peek() != EHTokIdentifier)
parseContext.declareBlock(loc, type); parseContext.declareBlock(loc, type);
} else { } else {
// Some qualifiers are set when parsing the type. Merge those with // Some qualifiers are set when parsing the type. Merge those with
......
...@@ -72,7 +72,7 @@ namespace glslang { ...@@ -72,7 +72,7 @@ namespace glslang {
bool acceptSamplerDeclarationDX9(TType&); bool acceptSamplerDeclarationDX9(TType&);
bool acceptSamplerState(); bool acceptSamplerState();
bool acceptFullySpecifiedType(TType&, const TAttributeMap&); bool acceptFullySpecifiedType(TType&, const TAttributeMap&);
bool acceptFullySpecifiedType(TType&, TIntermNode*& nodeList, const TAttributeMap&); bool acceptFullySpecifiedType(TType&, TIntermNode*& nodeList, const TAttributeMap&, bool forbidDeclarators = false);
bool acceptQualifier(TQualifier&); bool acceptQualifier(TQualifier&);
bool acceptLayoutQualifierList(TQualifier&); bool acceptLayoutQualifierList(TQualifier&);
bool acceptType(TType&); bool acceptType(TType&);
......
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