diff options
| author | Copilot <198982749+Copilot@users.noreply.github.com> | 2025-07-22 22:53:19 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-22 22:53:19 +0000 |
| commit | 8a36695f1f3abaf98831d4512e74ebd5bce1494e (patch) | |
| tree | 54705e7f8d6eea7db55e20f3de96ed4629f2b5ad /tests/language-feature | |
| parent | b16d4e955fdba3d68d156f944260f8b7a157fd4d (diff) | |
Fix public unscoped enum constants not visible across module boundaries (#7864)
* Initial plan
* Fix public unscoped enum constants visibility across module boundaries
Add visibility modifier copying in CompleteDecl for unscoped enum cases.
When synthesizing static const declarations for unscoped enum cases,
copy the visibility modifiers from the original enum declaration to
ensure they have the same visibility scope across module boundaries.
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Create new visibility modifier instances instead of sharing existing ones
Address reviewer feedback to avoid sharing modifier instances between
declarations since modifiers form a linked list. Now creates new
instances of the appropriate visibility modifier type (Public, Private,
or Internal) instead of reusing the existing instance.
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Move unscoped enum visibility tests into subdirectory structure
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Use createByNodeType for visibility modifier creation as suggested
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* format code (#7867)
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
Co-authored-by: slangbot <ellieh+slangbot@nvidia.com>
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'tests/language-feature')
| -rw-r--r-- | tests/language-feature/modules/unscoped-enum-visibility/unscoped_enum_lib.slang | 8 | ||||
| -rw-r--r-- | tests/language-feature/modules/unscoped-enum-visibility/unscoped_enum_user.slang | 29 |
2 files changed, 37 insertions, 0 deletions
diff --git a/tests/language-feature/modules/unscoped-enum-visibility/unscoped_enum_lib.slang b/tests/language-feature/modules/unscoped-enum-visibility/unscoped_enum_lib.slang new file mode 100644 index 000000000..7982d8baa --- /dev/null +++ b/tests/language-feature/modules/unscoped-enum-visibility/unscoped_enum_lib.slang @@ -0,0 +1,8 @@ +// Library module containing a public unscoped enum + +[UnscopedEnum] +public enum TestEnum +{ + CASE_A, + CASE_B +};
\ No newline at end of file diff --git a/tests/language-feature/modules/unscoped-enum-visibility/unscoped_enum_user.slang b/tests/language-feature/modules/unscoped-enum-visibility/unscoped_enum_user.slang new file mode 100644 index 000000000..e20f387fb --- /dev/null +++ b/tests/language-feature/modules/unscoped-enum-visibility/unscoped_enum_user.slang @@ -0,0 +1,29 @@ +//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type +// +// Test for public unscoped enum constants visibility across module boundaries +// +// This test verifies that unscoped enum constants are visible across module +// boundaries when the enum is declared as public. +// + +import unscoped_enum_lib; + +//TEST_INPUT: set outputBuffer = out ubuffer(data=[0 0 0 0], stride=4) +RWStructuredBuffer<uint> outputBuffer; + +[numthreads(1,1,1)] +void computeMain() +{ + // These should all be visible due to the public unscoped enum + TestEnum e1 = CASE_A; // Should work - unscoped access + TestEnum e2 = TestEnum.CASE_B; // Should work - scoped access + + // CHECK: 0 + outputBuffer[0] = (uint)e1; + // CHECK: 1 + outputBuffer[1] = (uint)e2; + // CHECK: 0 + outputBuffer[2] = (uint)CASE_A; + // CHECK: 1 + outputBuffer[3] = (uint)CASE_B; +}
\ No newline at end of file |
