summaryrefslogtreecommitdiffstats
path: root/tests/bugs/gh-2936.slang
blob: 20bfa1924be55e71623d0677f345fc2fc88d2e74 (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
43
44
45
46
47
48
49
50
51
52
53
//TEST(smoke,compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -shaderobj -output-using-type

// CHECK:        4
// CHECK-NEXT:  99
// CHECK-NEXT: 111
// CHECK-NEXT:  40

//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<int> outputBuffer;

[numthreads(1, 1, 1)]
void computeMain()
{
    outputBuffer[0] = f();
    outputBuffer[1] = g();
    outputBuffer[2] = h();
    outputBuffer[3] = k(30, 40);
}

static let x = 1;

func f() -> int
{
    let y = x; // should refer to the global x
    let x = 3;
    return x + y; // should refer to the local x
}
func g() -> int
{
    // Can we shadow this keyword
    int out;
    out = 99;
    return out;
}

static var input = 999;
func h() -> int
{
    // This should still parse as an identifier (it's a keyword, being shadowed
    // by something in a parent scope)
    input = 10;
    int input = input;
    input += 101;
    return input;
}

int k(int a, int b)
{
    int umax = max(a, b);

    int max = umax;
    return max;
}