diff options
| author | Yong He <yonghe@outlook.com> | 2023-12-11 16:13:32 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-11 16:13:32 -0800 |
| commit | ec0224edc3a867bbf059e790ad7b2a1a881a0705 (patch) | |
| tree | 9c56c3fd2dd11f79f597c152326d555d81414fc3 /tests/language-feature/namespaces/namespace-include | |
| parent | 12fcffaaaf2d1ffa2eefa680e2d7c9971e38a5db (diff) | |
Diagnose for invalid decl nesting + namespace lookup fixes. (#3397)
* Diagnose for invalid decl nesting.
* Fix.
* Fix.
* Fix.
* Fix `namespace` lookup and `using` resolution.
* fix project files.
* revert project files.
* Enhance namespace syntax, docs.
* Fixes.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests/language-feature/namespaces/namespace-include')
4 files changed, 59 insertions, 0 deletions
diff --git a/tests/language-feature/namespaces/namespace-include/a.slang b/tests/language-feature/namespaces/namespace-include/a.slang new file mode 100644 index 000000000..6660f590d --- /dev/null +++ b/tests/language-feature/namespaces/namespace-include/a.slang @@ -0,0 +1,28 @@ +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -shaderobj + +module a; + +__include b; + +namespace ns1 +{ +namespace ns2 +{ + int l() { return k(); } // should be able to find k() in b. +} +} + +using ns1.ns2; + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<int> outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(int3 dispatchThreadID: SV_DispatchThreadID) +{ + int tid = dispatchThreadID.x; + int inVal = tid; + int outVal = k() + l() + ns1.ns2.f(); + outputBuffer[tid] = outVal; + // CHECK: 7 +} diff --git a/tests/language-feature/namespaces/namespace-include/b.slang b/tests/language-feature/namespaces/namespace-include/b.slang new file mode 100644 index 000000000..95f8b388a --- /dev/null +++ b/tests/language-feature/namespaces/namespace-include/b.slang @@ -0,0 +1,11 @@ +implementing a; + +import m; + +namespace ns1 +{ +namespace ns2 +{ + int k() { return f() + g(); } // should be able to find ns1::ns2::f in m. +} +} diff --git a/tests/language-feature/namespaces/namespace-include/m.slang b/tests/language-feature/namespaces/namespace-include/m.slang new file mode 100644 index 000000000..4eb3db527 --- /dev/null +++ b/tests/language-feature/namespaces/namespace-include/m.slang @@ -0,0 +1,11 @@ +module m; + +__include m2; + +namespace ns1 +{ +namespace ns2 +{ + public int f() { return 1; } +} +} diff --git a/tests/language-feature/namespaces/namespace-include/m2.slang b/tests/language-feature/namespaces/namespace-include/m2.slang new file mode 100644 index 000000000..71a9be85a --- /dev/null +++ b/tests/language-feature/namespaces/namespace-include/m2.slang @@ -0,0 +1,9 @@ +implementing m; + +namespace ns1 +{ +namespace ns2 +{ + public int g() { return 2; } +} +} |
