diff options
| author | Yong He <yonghe@outlook.com> | 2017-12-27 21:51:56 -0500 |
|---|---|---|
| committer | Yong He <yonghe@outlook.com> | 2017-12-27 21:51:56 -0500 |
| commit | eaf3d840b16a8646ab4545487679c869eef500b7 (patch) | |
| tree | 3ae6f64ec51a2714ac06310723a1c320e91e5974 /tests | |
| parent | d55b56bc804f25d8390f1dc6b09ff9116ffcaf29 (diff) | |
Using a visitor to systematically replace lookup scopes of generic function's return type expression.
fixes #336
Add a `ReplaceScopeVisitor` to replace the scopes of the return type expression tree to use the generic decl's scope instead of module's scope after parser has determined the decl is a generic function header decl.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/compute/generics-syntax-2.slang | 28 | ||||
| -rw-r--r-- | tests/compute/generics-syntax-2.slang.expected.txt | 4 |
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/compute/generics-syntax-2.slang b/tests/compute/generics-syntax-2.slang new file mode 100644 index 000000000..29ed64825 --- /dev/null +++ b/tests/compute/generics-syntax-2.slang @@ -0,0 +1,28 @@ +//TEST(compute):COMPARE_COMPUTE:-xslang -use-ir +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out +// Confirm that generics syntax can be used in user +// code and generates valid output. + +RWStructuredBuffer<float> outputBuffer; + +struct GenStruct<T> +{ + T x; +}; + +GenStruct<T> test<T>(T val) +{ + GenStruct<T> rs; + rs.x = val; + return rs; +} + + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + float inVal = float(tid); + GenStruct<float> outVal = test(inVal); + outputBuffer[tid] = outVal.x; +}
\ No newline at end of file diff --git a/tests/compute/generics-syntax-2.slang.expected.txt b/tests/compute/generics-syntax-2.slang.expected.txt new file mode 100644 index 000000000..98798bd61 --- /dev/null +++ b/tests/compute/generics-syntax-2.slang.expected.txt @@ -0,0 +1,4 @@ +0 +3F800000 +40000000 +40400000
\ No newline at end of file |
