diff options
Diffstat (limited to 'tests/diagnostics')
| -rw-r--r-- | tests/diagnostics/autodiff-data-flow.slang.expected | 3 | ||||
| -rw-r--r-- | tests/diagnostics/generic-incorrect-default-arg.slang | 53 |
2 files changed, 53 insertions, 3 deletions
diff --git a/tests/diagnostics/autodiff-data-flow.slang.expected b/tests/diagnostics/autodiff-data-flow.slang.expected index 301f84985..6840bfd3c 100644 --- a/tests/diagnostics/autodiff-data-flow.slang.expected +++ b/tests/diagnostics/autodiff-data-flow.slang.expected @@ -3,9 +3,6 @@ standard error = { tests/diagnostics/autodiff-data-flow.slang(15): error 41020: derivative cannot be propagated through call to non-forward-differentiable function `nonDiff`, use 'no_diff' to clarify intention. val = nonDiff(x * 2.0f); ^ -tests/diagnostics/autodiff-data-flow.slang(22): error 41021: a differentiable function must have at least one differentiable output. -void g(float x) - ^ tests/diagnostics/autodiff-data-flow.slang(28): error 30510: loops inside a differentiable function need to provide either '[MaxIters(n)]' or '[ForceUnroll]' attribute. for (int i = 0; i < 5; i++) // Not ok, we can't infer the loop iterations because the body modifies induction var. ^~~ diff --git a/tests/diagnostics/generic-incorrect-default-arg.slang b/tests/diagnostics/generic-incorrect-default-arg.slang new file mode 100644 index 000000000..14192293c --- /dev/null +++ b/tests/diagnostics/generic-incorrect-default-arg.slang @@ -0,0 +1,53 @@ +//TEST:SIMPLE(filecheck=CHECK): -target hlsl -profile cs_5_0 -entry computeMain -line-directive-mode none + +// Check that user code can declare and use a generic +// `struct` type. + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<int> outputBuffer; + +interface ITest +{ + int doThing(int x); +}; + +struct Impl1 : ITest +{ + int doThing(int x) + { + return x * 2; + } +}; + +struct Impl2 +{ + int doSomethingElse(int x) + { + return x * 3; + } +}; + +__generic<T : ITest = Impl2> +// CHECK: tests/diagnostics/generic-incorrect-default-arg.slang([[@LINE-1]]): error 38029: type argument 'Impl2' does not conform to the required interface 'ITest' +struct GenStruct +{ + T obj; +}; + +int test(GenStruct gs, int val) +{ + return gs.obj.doThing(val); +} + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int tid = dispatchThreadID.x; + + int outVal = 0; + + GenStruct<Impl1> gs; + outVal += test(gs, tid); + + outputBuffer[tid] = outVal; +}
\ No newline at end of file |
