summaryrefslogtreecommitdiffstats
path: root/tests/diagnostics/generic-value-parameter-float-type.slang
blob: 0f9cde255e76d6ad622caa275680d2b8649cfdf7 (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): -target spirv

// Test that generic value parameters with float types are properly rejected

// CHECK: error 30624: generic value parameter type 'float' is not supported
struct ColorDefiner<let TMult : float>
{
    float4 color = {0.3, 0.7, 0.55, 1.0};

    float4 get_color() { return color * TMult; }
}

// CHECK: error 30624: generic value parameter type 'double' is not supported
struct DoubleDefiner<let TMult : double>
{
    float4 color = {0.3, 0.7, 0.55, 1.0};

    float4 get_color() { return color * float(TMult); }
}

// Integer types should work fine (no error expected)
struct IntDefiner<let TMult : int>
{
    float4 color = {0.3, 0.7, 0.55, 1.0};

    float4 get_color() { return color * TMult; }
}

// Enum types should work fine (no error expected)
enum Color { Red = 1, Green = 2, Blue = 3 }

struct EnumDefiner<let TMult : Color>
{
    float4 color = {0.3, 0.7, 0.55, 1.0};

    float4 get_color() { return color * int(TMult); }
}

void computeMain()
{
}