summaryrefslogtreecommitdiffstats
path: root/tests/language-feature
diff options
context:
space:
mode:
authorkaizhangNV <149626564+kaizhangNV@users.noreply.github.com>2025-03-06 22:38:28 -0600
committerGitHub <noreply@github.com>2025-03-06 20:38:28 -0800
commite1952dc8cf8f5b62d00ce114e353c5390cc6c37a (patch)
tree3c04706cb3c110fcf2f65f11eca8d37dcd42dcf1 /tests/language-feature
parent9d7d943db47dd7805a710431cf7eedc0bec8ecc7 (diff)
Fix a bug in default ctor synthesizing (#6527)
* Fix a bug in default ctor synthesizing - This is fix for the implementation bug, when a struct has explicit ctor we should not synthesize the default ctor anymore. - When invoke the synthesized ctor converted from initializer list, we should check if the struct is a c-style type if it struct has no synthesized ctor. In this case we should report error because it's invalid to use initializer list here. - The only exception is the unsized array, we still have to fall back to use the legacy initializer list logic to initialize the unsized array until we formalize a proper solution. - update test.
Diffstat (limited to 'tests/language-feature')
-rw-r--r--tests/language-feature/interfaces/default-construct-conformance.slang7
-rw-r--r--tests/language-feature/struct-field-initializers/struct-field-initializer-inherited.slang66
2 files changed, 6 insertions, 67 deletions
diff --git a/tests/language-feature/interfaces/default-construct-conformance.slang b/tests/language-feature/interfaces/default-construct-conformance.slang
index 4a6aed869..b68dc8a4c 100644
--- a/tests/language-feature/interfaces/default-construct-conformance.slang
+++ b/tests/language-feature/interfaces/default-construct-conformance.slang
@@ -33,6 +33,11 @@ struct TestAny : ITest
value = v;
}
+ __init()
+ {
+ value = 0;
+ }
+
uint getValue() { return value; }
}
@@ -183,4 +188,4 @@ void testMain(uint3 threadID: SV_DispatchThreadID)
}
expected[outputIdx++] = uint(-1);
-} \ No newline at end of file
+}
diff --git a/tests/language-feature/struct-field-initializers/struct-field-initializer-inherited.slang b/tests/language-feature/struct-field-initializers/struct-field-initializer-inherited.slang
deleted file mode 100644
index 954a1edbe..000000000
--- a/tests/language-feature/struct-field-initializers/struct-field-initializer-inherited.slang
+++ /dev/null
@@ -1,66 +0,0 @@
-//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain
-//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -emit-spirv-directly
-//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-cpu -compute -entry computeMain
-//TEST(smoke,compute):COMPARE_COMPUTE(filecheck-buffer=BUF):-dx12 -use-dxil -compute -entry computeMain
-
-//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer
-RWStructuredBuffer<int> outputBuffer;
-
-static int myTwo = 2;
-static int myThree = 1+2;
-
-struct DefaultStruct_base
-{
- int data0 = 1;
- int data1;
-
- __init()
- {
- data1 = 1;
- }
-};
-struct DefaultStruct1 : DefaultStruct_base
-{
- int data2 = 1;
-};
-struct DefaultStruct2 : DefaultStruct_base
-{
- int data2 = 1;
- __init()
- {
- if (data0 != 1)
- {
- data2 = 0;
- }
- }
-};
-struct DefaultStruct3 : DefaultStruct_base
-{
- __init()
- {
- }
-};
-struct DefaultStruct4 : DefaultStruct_base
-{
-};
-[numthreads(1, 1, 1)]
-void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID)
-{
- DefaultStruct1 s1 = {};
- DefaultStruct2 s2;
- DefaultStruct3 s3;
- DefaultStruct4 s4 = {};
- // BUF: 1
- outputBuffer[0] = true
- && s1.data0 == 1
- && s1.data1 == 1
- && s1.data2 == 1
- && s2.data0 == 1
- && s2.data1 == 1
- && s2.data2 == 1
- && s3.data0 == 1
- && s3.data1 == 1
- && s4.data0 == 1
- && s4.data1 == 1
- ;
-}