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/diagnostics | |
| 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/diagnostics')
3 files changed, 48 insertions, 0 deletions
diff --git a/tests/diagnostics/transitive-namespace-import.slang/a.slang b/tests/diagnostics/transitive-namespace-import.slang/a.slang new file mode 100644 index 000000000..257bf3717 --- /dev/null +++ b/tests/diagnostics/transitive-namespace-import.slang/a.slang @@ -0,0 +1,5 @@ +module a; +namespace ns +{ + public int fa() { return 1; } +} diff --git a/tests/diagnostics/transitive-namespace-import.slang/b.slang b/tests/diagnostics/transitive-namespace-import.slang/b.slang new file mode 100644 index 000000000..9d33d385d --- /dev/null +++ b/tests/diagnostics/transitive-namespace-import.slang/b.slang @@ -0,0 +1,6 @@ +module b; + +namespace ns +{ + public int f_b() { return 2; } +} diff --git a/tests/diagnostics/transitive-namespace-import.slang/test.slang b/tests/diagnostics/transitive-namespace-import.slang/test.slang new file mode 100644 index 000000000..a60e30a19 --- /dev/null +++ b/tests/diagnostics/transitive-namespace-import.slang/test.slang @@ -0,0 +1,37 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): + +module test; + +import b; + +void testFunc() +{ + // CHECK-NOT: {{.*}}([[# @LINE + 1]]): error + ns.f_b(); // OK. + // CHECK: {{.*}}([[# @LINE + 1]]): error 30027: + ns.f_a(); // Error. +} + +namespace ns +{ + void testFunc2() + { + // CHECK-NOT: {{.*}}([[# @LINE + 1]]): error + f_b(); // OK. + // CHECK: {{.*}}([[# @LINE + 1]]): error 30015: + f_a(); // Error. + } +} + +namespace ns2 +{ + using namespace ns; + + void testFunc3() + { + // CHECK-NOT: {{.*}}([[# @LINE + 1]]): error + f_b(); // OK. + // CHECK: {{.*}}([[# @LINE + 1]]): error 30015: + f_a(); // Error. + } +} |
