Skip to content

Commit

Permalink
Make destructors virtual in abstract classes for tests
Browse files Browse the repository at this point in the history
This fixes annoying warnings when compiling the generated code for additional symbols.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
  • Loading branch information
ddobrev committed Dec 18, 2019
1 parent 249578f commit c8e9f62
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 10 deletions.
24 changes: 24 additions & 0 deletions tests/CSharp/CSharp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@ void Baz::setMethod(ProtectedNestedEnum value)
{
}

AbstractProprietor::~AbstractProprietor()
{
}

int AbstractProprietor::getValue()
{
return m_value;
Expand Down Expand Up @@ -802,6 +806,10 @@ int MethodsWithDefaultValues::getA()
return m_foo.A;
}

HasPureVirtualWithDefaultArg::~HasPureVirtualWithDefaultArg()
{
}

HasOverridesWithChangedAccessBase::HasOverridesWithChangedAccessBase()
{
}
Expand Down Expand Up @@ -850,6 +858,10 @@ void HasOverridesWithIncreasedAccess::differentIncreasedAccessOverride()
{
}

AbstractWithProperty::~AbstractWithProperty()
{
}

IgnoredType PropertyWithIgnoredType::ignoredType()
{
return _ignoredType;
Expand Down Expand Up @@ -1150,6 +1162,10 @@ OverridePropertyFromIndirectPrimaryBaseBase::OverridePropertyFromIndirectPrimary
{
}

OverridePropertyFromIndirectPrimaryBaseBase::~OverridePropertyFromIndirectPrimaryBaseBase()
{
}

OverridePropertyFromDirectPrimaryBase::OverridePropertyFromDirectPrimaryBase()
{
}
Expand All @@ -1171,6 +1187,10 @@ AbstractOverrideFromSecondaryBase::AbstractOverrideFromSecondaryBase()
{
}

AbstractOverrideFromSecondaryBase::~AbstractOverrideFromSecondaryBase()
{
}

QObject::QObject()
{
}
Expand Down Expand Up @@ -1243,6 +1263,10 @@ InheritsFromHasSamePropertyInDerivedAbstractType::InheritsFromHasSamePropertyInD
{
}

InheritsFromHasSamePropertyInDerivedAbstractType::~InheritsFromHasSamePropertyInDerivedAbstractType()
{
}

MultipleInheritanceFieldOffsetsSecondaryBase::MultipleInheritanceFieldOffsetsSecondaryBase() : secondary(2)
{
}
Expand Down
9 changes: 9 additions & 0 deletions tests/CSharp/CSharp.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ struct QByteArrayDataPtr
class DLL_API AbstractProprietor
{
public:
virtual ~AbstractProprietor();
virtual int getValue();
virtual void setValue(int newValue) = 0;

Expand Down Expand Up @@ -480,6 +481,7 @@ class DLL_API MethodsWithDefaultValues : public Quux
class DLL_API HasPureVirtualWithDefaultArg
{
public:
virtual ~HasPureVirtualWithDefaultArg();
virtual void pureVirtualWithDefaultArg(Foo* foo = nullptr) = 0;
};

Expand Down Expand Up @@ -522,6 +524,7 @@ class DLL_API HasOverridesWithIncreasedAccess : public HasOverridesWithChangedAc
class DLL_API AbstractWithProperty
{
public:
virtual ~AbstractWithProperty();
virtual int property() = 0;
};

Expand Down Expand Up @@ -860,6 +863,7 @@ class DLL_API OverridePropertyFromIndirectPrimaryBaseBase
{
public:
OverridePropertyFromIndirectPrimaryBaseBase();
virtual ~OverridePropertyFromIndirectPrimaryBaseBase();
virtual int property() = 0;
virtual void setProperty(int value) = 0;
};
Expand All @@ -882,6 +886,7 @@ class DLL_API AbstractOverrideFromSecondaryBase : public Foo, public OverridePro
{
public:
AbstractOverrideFromSecondaryBase();
virtual ~AbstractOverrideFromSecondaryBase();
virtual void setProperty(int value) = 0;
};

Expand Down Expand Up @@ -938,6 +943,7 @@ class InheritsFromHasSamePropertyInDerivedAbstractType : public HasSamePropertyI
{
public:
InheritsFromHasSamePropertyInDerivedAbstractType();
virtual ~InheritsFromHasSamePropertyInDerivedAbstractType();
virtual int property() = 0;
};

Expand Down Expand Up @@ -993,6 +999,8 @@ namespace NamespaceB

class HasPrivateVirtualProperty
{
public:
virtual ~HasPrivateVirtualProperty();
private:
virtual int property();
virtual void protectedAbstractMethod() = 0;
Expand Down Expand Up @@ -1026,6 +1034,7 @@ struct iterator_category_with_traversal : Category, Traversal
class HasConflictWithAbstractProperty
{
public:
virtual ~HasConflictWithAbstractProperty();
int conflictWithProperty();
virtual int getConflictWithProperty() = 0;
};
Expand Down
31 changes: 31 additions & 0 deletions tests/Common/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ TestPacking8::~TestPacking8()
{
}

Foo::NestedAbstract::~NestedAbstract()
{
}

Foo::Foo()
{
auto p = new int[4];
Expand Down Expand Up @@ -355,6 +359,10 @@ int TestDelegates::CDecl(DelegateCDecl del)
return del(1);
}

AbstractFoo::~AbstractFoo()
{
}

int ImplementsAbstractFoo::pureFunction(typedefInOverride i)
{
return 5;
Expand All @@ -377,6 +385,10 @@ const AbstractFoo& ReturnsAbstractFoo::getFoo()
return i;
}

Exception::~Exception()
{
}

Ex2* DerivedException::clone()
{
return 0;
Expand Down Expand Up @@ -522,6 +534,10 @@ std::string& HasStdString::getStdString()
return s;
}

SomeNamespace::AbstractClass::~AbstractClass()
{
}

TestProperties::TestProperties() : Field(0), _refToPrimitiveInSetter(0),
_getterAndSetterWithTheSameName(0), _setterReturnsBoolean(0), _virtualSetterReturnsBoolean(0)
{
Expand Down Expand Up @@ -855,6 +871,10 @@ int DerivedClassVirtual::retInt(const Foo2& foo)
return 2;
}

DerivedClassAbstractVirtual::~DerivedClassAbstractVirtual()
{
}

DerivedClassOverrideAbstractVirtual::DerivedClassOverrideAbstractVirtual()
{
}
Expand Down Expand Up @@ -921,7 +941,10 @@ void FuncWithTypeAlias(custom_int_t i)

void FuncWithTemplateTypeAlias(TypeAliasTemplate<int> i)
{
}

HasAbstractOperator::~HasAbstractOperator()
{
}

HasOverloadsWithDifferentPointerKindsToSameType::HasOverloadsWithDifferentPointerKindsToSameType()
Expand Down Expand Up @@ -1136,3 +1159,11 @@ uint16_t TestStructWithCopyCtorByValue(StructWithCopyCtor s)
{
return s.mBits;
}

BaseCovariant::~BaseCovariant()
{
}

DerivedCovariant::~DerivedCovariant()
{
}
28 changes: 18 additions & 10 deletions tests/Common/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class DLL_API Foo
class NestedAbstract
{
public:
~NestedAbstract();
virtual int* abstractFunctionInNestedClass() = 0;
};

Expand Down Expand Up @@ -253,6 +254,7 @@ class DLL_API Hello
class DLL_API AbstractFoo
{
public:
virtual ~AbstractFoo();
virtual int pureFunction(int i = 0) = 0;
virtual int pureFunction1() = 0;
virtual int pureFunction2(bool* ok = 0) = 0;
Expand Down Expand Up @@ -291,6 +293,7 @@ typedef DerivedException Ex2;

struct DLL_API Exception : public Foo
{
virtual ~Exception();
virtual Ex1* clone() = 0;
};

Expand Down Expand Up @@ -540,11 +543,12 @@ class DLL_API SomeClassExtendingTheStruct : public SomeStruct

namespace SomeNamespace
{
class DLL_API AbstractClass
{
public:
virtual void AbstractMethod() = 0;
};
class DLL_API AbstractClass
{
public:
~AbstractClass();
virtual void AbstractMethod() = 0;
};
}

// Test operator overloads
Expand All @@ -553,11 +557,11 @@ class DLL_API ClassWithOverloadedOperators
public:
ClassWithOverloadedOperators();

operator char();
operator int();
operator short();
operator char();
operator int();
operator short();

virtual bool operator<(const ClassWithOverloadedOperators &other) const;
virtual bool operator<(const ClassWithOverloadedOperators &other) const;
};

ClassWithOverloadedOperators::ClassWithOverloadedOperators() {}
Expand Down Expand Up @@ -1022,6 +1026,7 @@ class DLL_API DerivedClassVirtual : public BaseClassVirtual
class DLL_API DerivedClassAbstractVirtual : public DerivedClassVirtual
{
public:
~DerivedClassAbstractVirtual();
virtual int retInt(const Foo& foo) = 0;
};

Expand Down Expand Up @@ -1262,6 +1267,7 @@ class UsesSpecialisationOfVoid
class DLL_API HasAbstractOperator
{
public:
~HasAbstractOperator();
virtual bool operator==(const HasAbstractOperator& other) = 0;
};

Expand Down Expand Up @@ -1529,10 +1535,12 @@ struct BaseCovariant;
typedef std::unique_ptr<BaseCovariant> PtrCovariant;

struct BaseCovariant {
virtual PtrCovariant clone() const = 0;
virtual ~BaseCovariant();
virtual PtrCovariant clone() const = 0;
};

struct DerivedCovariant: public BaseCovariant {
virtual ~DerivedCovariant();
std::unique_ptr<BaseCovariant> clone() const override {
return PtrCovariant(new DerivedCovariant());
}
Expand Down

0 comments on commit c8e9f62

Please sign in to comment.