blob: 6dd3c58e8c36729fbed8c0fdd793e1c691709439 (
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
//TEST:SIMPLE(filecheck=CHK): -target spirv -entry computeMain
// Using before assigning
float regular_undefined_use(out float3 v)
{
//CHK-DAG: ([[# @LINE + 1]]): warning 41015: use of uninitialized out parameter 'v'
float r = v.x + 1.0;
//CHK-DAG: ([[# @LINE + 1]]): warning 41018: returning without initializing out parameter 'v'
return r;
}
// Returning before assigning
float returning_undefined_use(out float x)
{
//CHK-DAG: ([[# @LINE + 1]]): warning 41018: returning without initializing out parameter 'x'
return 0;
}
// Implicit, still returning before assigning
void implicit_undefined_use(out float x)
{
//CHK-DAG: ([[# @LINE + 1]]): warning 41018: returning without initializing out parameter 'x'
}
// Warn on potential return paths
void control_flow_undefined(bool b, out float y)
{
if(b)
{
//CHK-DAG: ([[# @LINE + 1]]): warning 41018: returning without initializing out parameter 'y'
return;
}
y = 0;
return;
}
// No warnings if all paths are fine
void control_flow_defined(bool b, out float y)
{
if(b)
{
unused(y);
return;
}
y = 0;
return;
}
// Specialized handling for intrinsic asm
void instrincs_defined(float x, out float exp)
{
__intrinsic_asm "frexp";
}
// Specialized handling for target switches
void target_switching_undefined(float x, out float exp)
{
//CHK-DAG: ([[# @LINE + 2]]): warning 41018: returning without initializing out parameter 'exp'
__target_switch {}
}
void target_switching_defined(float x, out float exp)
{
__target_switch
{
case glsl: __intrinsic_asm "frexp";
}
}
void target_switching_blocks(uint x, out half v)
{
__target_switch
{
case hlsl:
if ((x & 2) == 0)
v = half(1);
else
v = half(1);
return;
case glsl:
case spirv:
{
if ((x & 2) == 0)
v = half(1);
else
v = half(1);
return;
}
}
}
//CHK-NOT: warning 41015
//CHK-NOT: warning 41018
[Shader("compute")]
[NumThreads(4, 1, 1)]
void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
{
}
|