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 | |
| 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')
4 files changed, 74 insertions, 2 deletions
diff --git a/tests/diagnostics/extension-visibility.slang.expected b/tests/diagnostics/extension-visibility.slang.expected index eed86715d..10033f24b 100644 --- a/tests/diagnostics/extension-visibility.slang.expected +++ b/tests/diagnostics/extension-visibility.slang.expected @@ -3,7 +3,7 @@ standard error = { tests/diagnostics/extension-visibility.slang(17): error 39999: could not specialize generic for arguments of type (MyThing) return helper(thing); ^ -tests/diagnostics/extension-visibility-a.slang(14): note 39999: see declaration of public func helper<T>(T) -> int +tests/diagnostics/extension-visibility-a.slang(14): note: see declaration of public func helper<T>(T) -> int public int helper<T : IThing>(T thing) ^~~~~~ } diff --git a/tests/diagnostics/generic-type-inference-fail.slang.expected b/tests/diagnostics/generic-type-inference-fail.slang.expected index 17cb28ca2..1910954d0 100644 --- a/tests/diagnostics/generic-type-inference-fail.slang.expected +++ b/tests/diagnostics/generic-type-inference-fail.slang.expected @@ -3,7 +3,7 @@ standard error = { tests/diagnostics/generic-type-inference-fail.slang(66): error 39999: could not specialize generic for arguments of type (int) var obj3 = CreateT_Assoc_Inner(1); // ERROR. ^ -tests/diagnostics/generic-type-inference-fail.slang(18): note 39999: see declaration of func CreateT_Assoc_Inner<T>(int) -> T.TAssoc +tests/diagnostics/generic-type-inference-fail.slang(18): note: see declaration of func CreateT_Assoc_Inner<T>(int) -> T.TAssoc T.TAssoc CreateT_Assoc_Inner<T:IInterface>(int inVal) ^~~~~~~~~~~~~~~~~~~ } 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() +{} |
