summaryrefslogtreecommitdiffstats
path: root/tests/bugs
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2020-03-20 16:59:15 -0400
committerGitHub <noreply@github.com>2020-03-20 16:59:15 -0400
commit884a9bcafc5fb9ae47245fa3ea9a6e64cb65a482 (patch)
tree6cd0de692b9e90bbdaef645ac2349a977740952f /tests/bugs
parentcc4c5b8dbbac648a7e914ff46f79293c1e122570 (diff)
Handling of switch with empty body (#1284)
* Added handling for empty switch body. Added test for empty switch. * Fix testing for case in switch.
Diffstat (limited to 'tests/bugs')
-rw-r--r--tests/bugs/empty-switch.slang29
-rw-r--r--tests/bugs/empty-switch.slang.expected.txt4
2 files changed, 33 insertions, 0 deletions
diff --git a/tests/bugs/empty-switch.slang b/tests/bugs/empty-switch.slang
new file mode 100644
index 000000000..104c63367
--- /dev/null
+++ b/tests/bugs/empty-switch.slang
@@ -0,0 +1,29 @@
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute
+//TEST(compute,vulkan):COMPARE_COMPUTE_EX:-vk -slang -compute
+//TEST(compute):COMPARE_COMPUTE_EX:-cpu -slang -compute
+//TEST(compute):COMPARE_COMPUTE_EX:-cuda -slang -compute
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out, name outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int index = int(dispatchThreadID.x);
+
+ int a = index;
+
+ // This is kind of silly - but it is a valid construct.
+ // We want to check condition expression is executed though
+ switch (++a)
+ {
+ }
+
+ switch (index)
+ {
+ // This should not be executed
+ a += 10;
+ }
+
+ outputBuffer[index] = a;
+} \ No newline at end of file
diff --git a/tests/bugs/empty-switch.slang.expected.txt b/tests/bugs/empty-switch.slang.expected.txt
new file mode 100644
index 000000000..94ebaf900
--- /dev/null
+++ b/tests/bugs/empty-switch.slang.expected.txt
@@ -0,0 +1,4 @@
+1
+2
+3
+4