summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/diagnostics/uninitialized-variable-name-in-error-message.slang37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/diagnostics/uninitialized-variable-name-in-error-message.slang b/tests/diagnostics/uninitialized-variable-name-in-error-message.slang
new file mode 100644
index 000000000..6e356e793
--- /dev/null
+++ b/tests/diagnostics/uninitialized-variable-name-in-error-message.slang
@@ -0,0 +1,37 @@
+//TEST:SIMPLE(filecheck=CHK):
+
+// Test if the variable name is a part of the error message
+// when it is used inside of for-loop
+
+RWStructuredBuffer<float> gInput;
+RWStructuredBuffer<float> outputBuffer;
+
+//CHK-DAG: ([[#@LINE+1]]): warning 41016: use of uninitialized variable 'a'
+float func1() { float a; return a; }
+
+//CHK-DAG: ([[#@LINE+1]]): warning 41016: use of uninitialized variable 'b'
+float func2() { float b; return b; }
+
+int test(int inVal)
+{
+ return inVal;
+}
+
+[Shader("compute")]
+[NumThreads(4, 1, 1)]
+void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int tid = dispatchThreadID.x;
+ int inVal1; // intentionally uninitialized
+ int inVal2; // intentionally uninitialized
+
+ for (int i = 0; i <2; ++i)
+ {
+ // CHK-DAG: ([[#@LINE+1]]): warning 41016: use of uninitialized variable 'inVal1'
+ int outVal = test(inVal1);
+
+ // CHK-DAG: ([[#@LINE+1]]): warning 41016: use of uninitialized variable 'inVal2'
+ outVal += test(inVal2);
+ outputBuffer[tid] = outVal;
+ }
+}