summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs/gh-3935.slang35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/bugs/gh-3935.slang b/tests/bugs/gh-3935.slang
new file mode 100644
index 000000000..9c8e9f19c
--- /dev/null
+++ b/tests/bugs/gh-3935.slang
@@ -0,0 +1,35 @@
+// Test if generic arguments using arithmetics are folded properly.
+
+//TEST:SIMPLE(filecheck=HLSL): -stage compute -entry computeMain -target hlsl
+
+RWStructuredBuffer<float> outputBuffer;
+
+__generic<let ArraySize:int>
+struct MyStruct
+{
+ int elems[ArraySize];
+};
+
+__generic<let ArraySize:int>
+MyStruct<ArraySize / 2> Reduce(MyStruct<ArraySize> o)
+{
+ MyStruct<ArraySize / 2> result;
+ //HLSL:[[ReturnType:MyStruct_[0-9]*]] Reduce
+ //HLSL:[[ReturnType]] result
+
+ result.elems[0] = o.elems[0];
+
+ // Error happened here as the return type differs
+ // from the type of "result".
+ return result;
+}
+
+[numthreads(1, 1, 1)]
+void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
+{
+ MyStruct<4> a;
+ a.elems[0] = 2;
+
+ let result = Reduce(a);
+ outputBuffer[0] = result.elems[0];
+}