summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/spirv-asm/wrong-assignment-opcode.slang
blob: 4afbb04172aefd2a6a6979b6505d09c81e70ff16 (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
//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK):

RWStructuredBuffer<float> buf;

//
// This test checks that we correctly diagnose trying to use the assignment and
// typed assignment syntax with operands with no result type or id.
//
// By virtue of these tests being in the same file, we also check the error
// recovery for the asm block parser.
//
int foo(const int constParam)
{
    // Doesn't have a result type
    spirv_asm
    {
        %bar : %wrong = OpTypeInt 32 0
        // CHECK: wrong-assignment-opcode.slang([[#@LINE-1]]): error 29104: cannot use this 'x : <type> = OpTypeInt...' syntax because OpTypeInt does not have a <result-type-id> operand

    };

    // Doesn't have a result value
    spirv_asm
    {
        %foo = OpStore 1 2;
        // CHECK: wrong-assignment-opcode.slang([[#@LINE-1]]): error 29104: cannot use this 'x = OpStore...' syntax because OpStore does not have a <result-id> operand
    };

    // garbage
    spirv_asm
    {
        %foo =;
        // CHECK: wrong-assignment-opcode.slang([[#@LINE-1]]): error 20003: unexpected ';'
        %foo :;
        // CHECK: wrong-assignment-opcode.slang([[#@LINE-1]]): error 20003: unexpected ';'
        %foo : bar;
        // CHECK: wrong-assignment-opcode.slang([[#@LINE-1]]): error 20001: unexpected ';', expected '='
        %foo : bar =;
        // CHECK: wrong-assignment-opcode.slang([[#@LINE-1]]): error 20003: unexpected ';'
    };
}