diff options
| author | Yong He <yonghe@outlook.com> | 2024-02-06 16:30:31 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-06 16:30:31 -0800 |
| commit | ab41d548db376c6b52869004d1b6e21b88b4c9c8 (patch) | |
| tree | 61aacddad8b8c56d77cf63ab3b650fdb28bbe0e6 /tests/language-feature | |
| parent | 6365e00179179f2bc0bc25af3d51d528501498d5 (diff) | |
Improve Capability System (#3555)
* Improve capability system.
* Update documentation.
* Tuning semantics.
* LSP: hierarchical diagnostics.
* Fix test.
* Fix test.
Diffstat (limited to 'tests/language-feature')
| -rw-r--r-- | tests/language-feature/capability/capability3.slang | 47 | ||||
| -rw-r--r-- | tests/language-feature/capability/capability4.slang | 25 |
2 files changed, 72 insertions, 0 deletions
diff --git a/tests/language-feature/capability/capability3.slang b/tests/language-feature/capability/capability3.slang new file mode 100644 index 000000000..f7ba1d793 --- /dev/null +++ b/tests/language-feature/capability/capability3.slang @@ -0,0 +1,47 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv -emit-spirv-directly -entry main -stage compute + +// Test that capabilities can be declared on module. + +[require(glsl)] +[require(spirv)] +module test; + +void f() +{ + __require_capability glsl; +} + +// CHECK: ([[# @LINE+1]]): error 36108 +public void g() +{ + __require_capability spvAtomicFloat16AddEXT; +} + +void l() +{ + __target_switch + { + case glsl: + f(); + return; + case spirv: + __require_capability spvAtomicFloat16AddEXT; + return; + } +} + +// CHECK: ([[# @LINE+1]]): error 36104: {{.*}} +public void use() +{ + l(); // Error +} + +// CHECK-NOT: ([[# @LINE+1]]): error +[require(spirv, spvAtomicFloat16AddEXT)] +public void use1() +{ + l(); // Error +} + +void main() +{}
\ No newline at end of file diff --git a/tests/language-feature/capability/capability4.slang b/tests/language-feature/capability/capability4.slang new file mode 100644 index 000000000..fce1f78ac --- /dev/null +++ b/tests/language-feature/capability/capability4.slang @@ -0,0 +1,25 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv -emit-spirv-directly -entry main -stage compute + +// Check that a non-static member method implictly requires capabilities +// defined in ThisType. + +[require(hlsl)] +struct Type +{ + int member; + [require(glsl)] + [mutating] + // CHECK: ([[# @LINE+1]]): error 36108: + void f() + { + } + + [require(glsl)] + // CHECK-NOT: ([[# @LINE+1]]): error 36108: + static void f1() + { + } +} + +void main() +{} |
