diff options
| author | Yong He <yonghe@outlook.com> | 2024-03-27 12:21:07 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-27 12:21:07 -0700 |
| commit | 8395acfa0ad8379011e4470b94362189cafac93f (patch) | |
| tree | 4395205a3969d2cd3d3b6407fa77786b26aec809 /tests | |
| parent | c5369d507341e6b6fe64d4e6f26e194cd39235ca (diff) | |
Fix lookup to prevent finding `typedef` itself. (#3848)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/bugs/gh-3845-2.slang | 26 | ||||
| -rw-r--r-- | tests/bugs/gh-3845.slang | 27 |
2 files changed, 53 insertions, 0 deletions
diff --git a/tests/bugs/gh-3845-2.slang b/tests/bugs/gh-3845-2.slang new file mode 100644 index 000000000..06a3d1c99 --- /dev/null +++ b/tests/bugs/gh-3845-2.slang @@ -0,0 +1,26 @@ +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-shaderobj -output-using-type +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-shaderobj -vk -output-using-type + +struct Foo {float v;}; + +namespace foo { + typedef ::Foo Foo; // unexpected '::', expected identifier; works in dxc/hlsl + + float test(Foo f) + { + return f.v; + } +} + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer<float> outputBuffer; + +[numthreads(4, 1, 1)] +[shader("compute")] +void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID) +{ + Foo f; + f.v = 1.0; + // CHECK: 1.0 + outputBuffer[0] = foo.test(f); +} diff --git a/tests/bugs/gh-3845.slang b/tests/bugs/gh-3845.slang new file mode 100644 index 000000000..fe8da5acf --- /dev/null +++ b/tests/bugs/gh-3845.slang @@ -0,0 +1,27 @@ +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-shaderobj -output-using-type +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-shaderobj -vk -output-using-type + + +struct Foo {float v;}; + +namespace foo { + typedef Foo Foo; // cyclic reference 'Foo'; allowed in dxc/hlsl + + float test(Foo f) + { + return f.v; + } +} + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer<float> outputBuffer; + +[numthreads(4, 1, 1)] +[shader("compute")] +void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID) +{ + Foo f; + f.v = 1.0; + // CHECK: 1.0 + outputBuffer[0] = foo.test(f); +} |
