diff options
| -rw-r--r-- | source/slang/slang-parser.cpp | 5 | ||||
| -rw-r--r-- | tests/bugs/multiple-attributes-without-comma.slang | 25 |
2 files changed, 28 insertions, 2 deletions
diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp index 5022a9fdd..fdc5c19b5 100644 --- a/source/slang/slang-parser.cpp +++ b/source/slang/slang-parser.cpp @@ -966,6 +966,7 @@ namespace Slang if (AdvanceIfMatch(parser, MatchedTokenType::Parentheses)) break; + parser->ReadToken(TokenType::Comma); } } @@ -975,8 +976,8 @@ namespace Slang if (AdvanceIfMatch(parser, MatchedTokenType::SquareBrackets)) break; - parser->ReadToken(TokenType::Comma); - + // If there is a comma consume it. It appears that the comma is optional. + AdvanceIf(parser, TokenType::Comma); } if (hasDoubleBracket) diff --git a/tests/bugs/multiple-attributes-without-comma.slang b/tests/bugs/multiple-attributes-without-comma.slang new file mode 100644 index 000000000..51683e4ef --- /dev/null +++ b/tests/bugs/multiple-attributes-without-comma.slang @@ -0,0 +1,25 @@ +// multiple-attributes-without-comma.slang + +// Test that `,` is not need between attributes + +//TEST:SIMPLE(filecheck=CHECK):-target glsl -entry main -stage fragment -line-directive-mode none + +//CHECK: layout(location = 0, index = 1) + +struct FragmentOutput +{ + [[vk::location(0)]] + float4 a : SV_Target0; + + [[vk::location(0) vk::index(1)]] + float4 b : SV_Target1; +} + +[shader("fragment")] +FragmentOutput main(float4 v : V) +{ + FragmentOutput f = {}; + f.a = v; + f.b = v; + return f; +} |
