From 8395acfa0ad8379011e4470b94362189cafac93f Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 27 Mar 2024 12:21:07 -0700 Subject: Fix lookup to prevent finding `typedef` itself. (#3848) --- tests/bugs/gh-3845-2.slang | 26 ++++++++++++++++++++++++++ tests/bugs/gh-3845.slang | 27 +++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 tests/bugs/gh-3845-2.slang create mode 100644 tests/bugs/gh-3845.slang (limited to 'tests') 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 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 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); +} -- cgit v1.2.3