From 605204374658fc6d7f647f9a57e9e322b8c83100 Mon Sep 17 00:00:00 2001 From: kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> Date: Wed, 29 Jan 2025 12:13:13 -0600 Subject: Fix the type coerce issue (#6215) * Fix the type coerce issue When synthesize the default ctor, if there is a base type we will synthesize an InvokeExpr to call base type's default ctor as well. But we should use the type of the inheritanceDecl instead of base struct decl. --- .../initializer-lists/inheritance-generic.slang | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/language-feature/initializer-lists/inheritance-generic.slang (limited to 'tests') diff --git a/tests/language-feature/initializer-lists/inheritance-generic.slang b/tests/language-feature/initializer-lists/inheritance-generic.slang new file mode 100644 index 000000000..c916178b8 --- /dev/null +++ b/tests/language-feature/initializer-lists/inheritance-generic.slang @@ -0,0 +1,26 @@ +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER):-shaderobj -vk +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER):-shaderobj + +struct Base +{ + int a = 1; +} + +struct Derived: Base +{ + bool x; + bool y; +} + +//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=result +RWStructuredBuffer result; + +[shader("compute")] +[numthreads(1, 1, 1)] +void computeMain() +{ + Derived<3> d; + + // BUFFER: 1 + result[0] = d.a; +} -- cgit v1.2.3