Skip to content

Commit

Permalink
Fixed a regression causing incorrect sizes of types derived from temp…
Browse files Browse the repository at this point in the history
…late instantiations.

Signed-off-by: Dimitar Dobrev <[email protected]>
  • Loading branch information
ddobrev committed Sep 20, 2015
1 parent b908881 commit c183200
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/Generator/Passes/CheckAbiParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ private static bool HasFieldsOrVirtuals(Class @class)
{
if (@class.Fields.Count > 0 || @class.IsDynamic)
return true;
return @class.HasBaseClass && @class.Bases.Any(@base => @base.IsClass && HasFieldsOrVirtuals(@base.Class));
return @class.Bases.Any(@base => @base.IsClass && @base.Class != @class &&
HasFieldsOrVirtuals(@base.Class));
}
}
}
6 changes: 6 additions & 0 deletions tests/CSharp/CSharp.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -437,4 +437,10 @@ public void TestConversionForCtorWithDefaultParams()
Assert.That(foo.A, Is.EqualTo(15));
}
}

[Test]
public unsafe void TestSizeOfDerivesFromTemplateInstantiation()
{
Assert.That(sizeof(DerivesFromTemplateInstantiation.Internal), Is.EqualTo(sizeof(int)));
}
}
9 changes: 9 additions & 0 deletions tests/CSharp/CSharp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -789,3 +789,12 @@ void TestOutTypeInterfaces::funcTryInterfaceTypePtrOut(CS_OUT TestParamToInterfa
void TestOutTypeInterfaces::funcTryInterfaceTypeOut(CS_OUT TestParamToInterfacePassBaseTwo classTry)
{
}

template <typename T>
TemplateWithDependentField<T>::TemplateWithDependentField()
{
}

DerivesFromTemplateInstantiation::DerivesFromTemplateInstantiation()
{
}
20 changes: 17 additions & 3 deletions tests/CSharp/CSharp.h
Original file line number Diff line number Diff line change
Expand Up @@ -708,12 +708,26 @@ class OverrideFromIndirectSecondaryBase : public OverrideFromDirectSecondaryBase
class DLL_API TestVariableWithFixedArrayType
{
public:
static Foo variableWithFixedArrayType[2];
static Foo variableWithFixedArrayType[2];
};

class DLL_API TestOutTypeInterfaces
{
public:
void funcTryInterfaceTypePtrOut(CS_OUT TestParamToInterfacePassBaseTwo* classTry);
void funcTryInterfaceTypeOut(CS_OUT TestParamToInterfacePassBaseTwo classTry);
void funcTryInterfaceTypePtrOut(CS_OUT TestParamToInterfacePassBaseTwo* classTry);
void funcTryInterfaceTypeOut(CS_OUT TestParamToInterfacePassBaseTwo classTry);
};

template <typename T>
class TemplateWithDependentField
{
public:
TemplateWithDependentField();
T t;
};

class DerivesFromTemplateInstantiation : public TemplateWithDependentField<int>
{
public:
DerivesFromTemplateInstantiation();
};
5 changes: 4 additions & 1 deletion tests/Common/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -842,4 +842,7 @@ namespace boost
{
template <class T> struct is_member_pointer_cv { static const bool value = false; };
template <class T, class U>struct is_member_pointer_cv<T U::*> { static const bool value = true; };
}
}

template <std::size_t N, std::size_t... I>
struct build_index_impl : build_index_impl<N - 1, N - 1, I...> {};

0 comments on commit c183200

Please sign in to comment.