Skip to content

Commit c183200

Browse files
committed
Fixed a regression causing incorrect sizes of types derived from template instantiations.
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent b908881 commit c183200

File tree

5 files changed

+38
-5
lines changed

5 files changed

+38
-5
lines changed

Diff for: src/Generator/Passes/CheckAbiParameters.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ private static bool HasFieldsOrVirtuals(Class @class)
8787
{
8888
if (@class.Fields.Count > 0 || @class.IsDynamic)
8989
return true;
90-
return @class.HasBaseClass && @class.Bases.Any(@base => @base.IsClass && HasFieldsOrVirtuals(@base.Class));
90+
return @class.Bases.Any(@base => @base.IsClass && @base.Class != @class &&
91+
HasFieldsOrVirtuals(@base.Class));
9192
}
9293
}
9394
}

Diff for: tests/CSharp/CSharp.Tests.cs

+6
Original file line numberDiff line numberDiff line change
@@ -437,4 +437,10 @@ public void TestConversionForCtorWithDefaultParams()
437437
Assert.That(foo.A, Is.EqualTo(15));
438438
}
439439
}
440+
441+
[Test]
442+
public unsafe void TestSizeOfDerivesFromTemplateInstantiation()
443+
{
444+
Assert.That(sizeof(DerivesFromTemplateInstantiation.Internal), Is.EqualTo(sizeof(int)));
445+
}
440446
}

Diff for: tests/CSharp/CSharp.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -789,3 +789,12 @@ void TestOutTypeInterfaces::funcTryInterfaceTypePtrOut(CS_OUT TestParamToInterfa
789789
void TestOutTypeInterfaces::funcTryInterfaceTypeOut(CS_OUT TestParamToInterfacePassBaseTwo classTry)
790790
{
791791
}
792+
793+
template <typename T>
794+
TemplateWithDependentField<T>::TemplateWithDependentField()
795+
{
796+
}
797+
798+
DerivesFromTemplateInstantiation::DerivesFromTemplateInstantiation()
799+
{
800+
}

Diff for: tests/CSharp/CSharp.h

+17-3
Original file line numberDiff line numberDiff line change
@@ -708,12 +708,26 @@ class OverrideFromIndirectSecondaryBase : public OverrideFromDirectSecondaryBase
708708
class DLL_API TestVariableWithFixedArrayType
709709
{
710710
public:
711-
static Foo variableWithFixedArrayType[2];
711+
static Foo variableWithFixedArrayType[2];
712712
};
713713

714714
class DLL_API TestOutTypeInterfaces
715715
{
716716
public:
717-
void funcTryInterfaceTypePtrOut(CS_OUT TestParamToInterfacePassBaseTwo* classTry);
718-
void funcTryInterfaceTypeOut(CS_OUT TestParamToInterfacePassBaseTwo classTry);
717+
void funcTryInterfaceTypePtrOut(CS_OUT TestParamToInterfacePassBaseTwo* classTry);
718+
void funcTryInterfaceTypeOut(CS_OUT TestParamToInterfacePassBaseTwo classTry);
719+
};
720+
721+
template <typename T>
722+
class TemplateWithDependentField
723+
{
724+
public:
725+
TemplateWithDependentField();
726+
T t;
727+
};
728+
729+
class DerivesFromTemplateInstantiation : public TemplateWithDependentField<int>
730+
{
731+
public:
732+
DerivesFromTemplateInstantiation();
719733
};

Diff for: tests/Common/Common.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -842,4 +842,7 @@ namespace boost
842842
{
843843
template <class T> struct is_member_pointer_cv { static const bool value = false; };
844844
template <class T, class U>struct is_member_pointer_cv<T U::*> { static const bool value = true; };
845-
}
845+
}
846+
847+
template <std::size_t N, std::size_t... I>
848+
struct build_index_impl : build_index_impl<N - 1, N - 1, I...> {};

0 commit comments

Comments
 (0)