diff options
Diffstat (limited to 'source/slang/slang-type-layout.cpp')
| -rw-r--r-- | source/slang/slang-type-layout.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/source/slang/slang-type-layout.cpp b/source/slang/slang-type-layout.cpp index e791efadb..30c41d0fe 100644 --- a/source/slang/slang-type-layout.cpp +++ b/source/slang/slang-type-layout.cpp @@ -3,6 +3,7 @@ #include "slang-syntax.h" #include "slang-ir-insts.h" +#include "slang-check-impl.h" #include "../compiler-core/slang-artifact-desc-util.h" @@ -3331,7 +3332,7 @@ void StructTypeLayoutBuilder::beginLayoutIfNeeded( } RefPtr<VarLayout> StructTypeLayoutBuilder::addField( - DeclRef<VarDeclBase> field, + DeclRef<Decl> field, TypeLayoutResult fieldResult) { SLANG_ASSERT(m_typeLayout); @@ -4082,6 +4083,16 @@ static TypeLayoutResult _createTypeLayout( _addLayout(context, type, typeLayout); + // Add all base fields first. + for (auto inheritanceDeclRef : getMembersOfType<InheritanceDecl>(context.astBuilder, structDeclRef)) + { + auto baseType = getSup(context.astBuilder, inheritanceDeclRef); + if (isInterfaceType(baseType)) + continue; + auto baseTypeLayout = _createTypeLayout(context, baseType); + typeLayoutBuilder.addField(inheritanceDeclRef, baseTypeLayout); + } + // First, add all fields with explicit offsets. for (auto field : getFields(context.astBuilder, structDeclRef, MemberFilterStyle::Instance)) { |
