summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/language-feature/inheritance/derived-struct-init-list.slang42
-rw-r--r--tests/language-feature/inheritance/derived-struct-init-list.slang.expected.txt4
2 files changed, 46 insertions, 0 deletions
diff --git a/tests/language-feature/inheritance/derived-struct-init-list.slang b/tests/language-feature/inheritance/derived-struct-init-list.slang
new file mode 100644
index 000000000..edcb685e6
--- /dev/null
+++ b/tests/language-feature/inheritance/derived-struct-init-list.slang
@@ -0,0 +1,42 @@
+// derived-struct-init-list.slang
+
+//TEST(compute):COMPARE_COMPUTE:
+
+// Test that use of an initializer list (especially
+// an empty initializer list) is still possible
+// when using `struct` inheritance.
+
+struct Base
+{
+ int a = 1;
+}
+
+struct Derived : Base
+{
+ int b = 2;
+
+ void write(inout int val) { val = val*0x100 + a*0x10 + b; }
+}
+
+int test(int val)
+{
+ Derived x = {};
+ Derived y = { val, val+1 };
+
+ int result = 1;
+ x.write(result);
+ y.write(result);
+ return result;
+}
+
+//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)
+{
+ uint tid = dispatchThreadID.x;
+ int inVal = tid;
+ int outVal = test(inVal);
+ outputBuffer[tid] = outVal;
+}
diff --git a/tests/language-feature/inheritance/derived-struct-init-list.slang.expected.txt b/tests/language-feature/inheritance/derived-struct-init-list.slang.expected.txt
new file mode 100644
index 000000000..373286856
--- /dev/null
+++ b/tests/language-feature/inheritance/derived-struct-init-list.slang.expected.txt
@@ -0,0 +1,4 @@
+11201
+11212
+11223
+11234