summaryrefslogtreecommitdiffstats
path: root/tests/diagnostics
diff options
context:
space:
mode:
authorJay Kwak <82421531+jkwak-work@users.noreply.github.com>2025-02-24 16:25:19 -0800
committerGitHub <noreply@github.com>2025-02-24 16:25:19 -0800
commitf90a7631a10d7dcc1427bfda85f66c539c50af5d (patch)
treee5bda5e3a58a8619eeab73f9a99c628a701e4767 /tests/diagnostics
parent73a8d74bdf2849ce3290d8bf8aaf7e1c59f7bc5b (diff)
Clone name hint decoration when emiting Undefined (#6415)
* Clone name hint decoration when emiting Undefined When emiting "Undefined", we lost the information of where it was synthasized from. This prevents us from providing more helpful error messages. The issue was the when we handle "IRLoop", the inputs parameters to the Phi didn't clone the name hint decoration. This commit clones them when emiting "Undefined". * Adding more test case --------- Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tests/diagnostics')
-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;
+ }
+}