diff options
| -rw-r--r-- | source/slang/slang-parser.cpp | 4 | ||||
| -rw-r--r-- | tests/bugs/gh-4457.slang | 27 |
2 files changed, 29 insertions, 2 deletions
diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp index e6913c6c0..aefe7f362 100644 --- a/source/slang/slang-parser.cpp +++ b/source/slang/slang-parser.cpp @@ -5349,9 +5349,9 @@ namespace Slang { statement = ParseExpressionStatement(); } - else if (LookAheadToken(TokenType::Identifier)) + else if (LookAheadToken(TokenType::Identifier) || LookAheadToken(TokenType::Scope)) { - if (LookAheadToken(TokenType::Colon, 1)) + if (LookAheadToken(TokenType::Identifier) && LookAheadToken(TokenType::Colon, 1)) { // An identifier followed by an ":" is a label. return parseLabelStatement(); diff --git a/tests/bugs/gh-4457.slang b/tests/bugs/gh-4457.slang new file mode 100644 index 000000000..e456b14f3 --- /dev/null +++ b/tests/bugs/gh-4457.slang @@ -0,0 +1,27 @@ +//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-vk -compute -shaderobj -output-using-type + +// This tests if the scope(::) is recognized for a local variable declaration. + +//TEST_INPUT: ubuffer(data=[0 0], stride=4):out,name outputBuffer +RWStructuredBuffer<int> outputBuffer; + +[UnscopedEnum] +enum Number { + First = 1, + Second, +}; + +static ::Number foo = First; + +[numthreads(4, 1, 1)] +void computeMain(int3 dispatchThreadID: SV_DispatchThreadID) +{ + // The scope(::) should be recognized + static ::Number bar = Second; + + //CHK:1 + //CHK-NEXT:2 + outputBuffer[0] = int(foo); + outputBuffer[1] = int(bar); +} + |
