blob: 3c7c874c90713a972f364f0f074710169f5030a6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
// mutating-impl-of-non-mutating-req.slang
//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK):-target hlsl -entry main
interface IThing
{
int processValue(int inValue);
}
struct Counter : IThing
{
int state;
// CHECK: ([[# @LINE+1]]): error 38105:
[mutating] int processValue(int inValue)
{
int result = state;
state += inValue;
return state;
}
}
int helper<T : IThing>(T thing, int value)
{
return thing.processValue(value);
}
int test(int value)
{
Counter counter = { value };
return helper(counter, value);
}
cbuffer C
{
int gValue;
}
[shader("fragment")]
int main() : SV_Target
{
return test(gValue);
}
|