From 6e67c03dc0225fc66343546b14e902b9d238b1a3 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 14 Mar 2012 13:27:56 +0100 Subject: Enable -Wnon-virtual-dtor for GCC 4.6 ...which has the necessary features to support it. Change a lot of classes to either contain a protected non-virtual dtor (which is backwards compatible, so even works for cppumaker-generated UNO headers) or a public virtual one. cppuhelper/propertysetmixin.hxx still needs to disable the warning, as the relevant class has a non-virtual dtor but friends, which would still cause GCC to warn. Includes a patch for libcmis, intended to be upstreamed. --- cppuhelper/inc/cppuhelper/implbase.hxx | 3 +++ cppuhelper/inc/cppuhelper/implbase1.hxx | 3 +++ cppuhelper/inc/cppuhelper/implbase10.hxx | 3 +++ cppuhelper/inc/cppuhelper/implbase11.hxx | 3 +++ cppuhelper/inc/cppuhelper/implbase12.hxx | 3 +++ cppuhelper/inc/cppuhelper/implbase2.hxx | 3 +++ cppuhelper/inc/cppuhelper/implbase3.hxx | 3 +++ cppuhelper/inc/cppuhelper/implbase4.hxx | 3 +++ cppuhelper/inc/cppuhelper/implbase5.hxx | 3 +++ cppuhelper/inc/cppuhelper/implbase6.hxx | 3 +++ cppuhelper/inc/cppuhelper/implbase7.hxx | 3 +++ cppuhelper/inc/cppuhelper/implbase8.hxx | 3 +++ cppuhelper/inc/cppuhelper/implbase9.hxx | 3 +++ cppuhelper/inc/cppuhelper/propertysetmixin.hxx | 7 +++++++ cppuhelper/inc/cppuhelper/propshlp.hxx | 12 +++++++----- cppuhelper/source/exc_thrower.cxx | 2 ++ cppuhelper/unotypes/Makefile | 7 ++++--- 17 files changed, 59 insertions(+), 8 deletions(-) (limited to 'cppuhelper') diff --git a/cppuhelper/inc/cppuhelper/implbase.hxx b/cppuhelper/inc/cppuhelper/implbase.hxx index 34cfed2350f0..85051fb407a2 100644 --- a/cppuhelper/inc/cppuhelper/implbase.hxx +++ b/cppuhelper/inc/cppuhelper/implbase.hxx @@ -186,6 +186,7 @@ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelperBase##N \ , __PUBLIC_IFC##N \ { \ protected: \ + ~ImplHelperBase##N() throw () {} \ ClassData & SAL_CALL getClassData( ClassDataBase & s_aCD ) SAL_THROW(()) \ { \ ClassData & rCD = * static_cast< ClassData * >( &s_aCD ); \ @@ -221,6 +222,8 @@ public: \ { return this->getClassData( s_aCD ).getTypes(); } \ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \ { return this->getClassData( s_aCD ).getImplementationId(); } \ +protected: \ + ~ImplHelper##N() throw () {} \ }; \ template< __CLASS_IFC##N > \ class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakImplHelper##N \ diff --git a/cppuhelper/inc/cppuhelper/implbase1.hxx b/cppuhelper/inc/cppuhelper/implbase1.hxx index d4cbeea67dd1..c49c9162a14c 100644 --- a/cppuhelper/inc/cppuhelper/implbase1.hxx +++ b/cppuhelper/inc/cppuhelper/implbase1.hxx @@ -85,6 +85,9 @@ namespace cppu { return ImplHelper_getTypes( cd::get() ); } virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException) { return ImplHelper_getImplementationId( cd::get() ); } + + protected: + ~ImplHelper1() throw () {} }; /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and com::sun::star::uno::XInterface which supports weak mechanism to be held weakly diff --git a/cppuhelper/inc/cppuhelper/implbase10.hxx b/cppuhelper/inc/cppuhelper/implbase10.hxx index 1ea06d4bf935..8a51770601f3 100644 --- a/cppuhelper/inc/cppuhelper/implbase10.hxx +++ b/cppuhelper/inc/cppuhelper/implbase10.hxx @@ -94,6 +94,9 @@ namespace cppu { return ImplHelper_getTypes( cd::get() ); } virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException) { return ImplHelper_getImplementationId( cd::get() ); } + + protected: + ~ImplHelper10() throw () {} }; /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and com::sun::star::uno::XInterface which supports weak mechanism to be held weakly diff --git a/cppuhelper/inc/cppuhelper/implbase11.hxx b/cppuhelper/inc/cppuhelper/implbase11.hxx index bbcd67533c03..4c1a307ae116 100644 --- a/cppuhelper/inc/cppuhelper/implbase11.hxx +++ b/cppuhelper/inc/cppuhelper/implbase11.hxx @@ -95,6 +95,9 @@ namespace cppu { return ImplHelper_getTypes( cd::get() ); } virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException) { return ImplHelper_getImplementationId( cd::get() ); } + + protected: + ~ImplHelper11() throw () {} }; /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and com::sun::star::uno::XInterface which supports weak mechanism to be held weakly diff --git a/cppuhelper/inc/cppuhelper/implbase12.hxx b/cppuhelper/inc/cppuhelper/implbase12.hxx index 4211abc4c99a..934dfbe55b83 100644 --- a/cppuhelper/inc/cppuhelper/implbase12.hxx +++ b/cppuhelper/inc/cppuhelper/implbase12.hxx @@ -96,6 +96,9 @@ namespace cppu { return ImplHelper_getTypes( cd::get() ); } virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException) { return ImplHelper_getImplementationId( cd::get() ); } + + protected: + ~ImplHelper12() throw () {} }; /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and com::sun::star::uno::XInterface which supports weak mechanism to be held weakly diff --git a/cppuhelper/inc/cppuhelper/implbase2.hxx b/cppuhelper/inc/cppuhelper/implbase2.hxx index 39983d61df39..b77947a8cdc8 100644 --- a/cppuhelper/inc/cppuhelper/implbase2.hxx +++ b/cppuhelper/inc/cppuhelper/implbase2.hxx @@ -85,6 +85,9 @@ namespace cppu { return ImplHelper_getTypes( cd::get() ); } virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException) { return ImplHelper_getImplementationId( cd::get() ); } + + protected: + ~ImplHelper2() throw () {} }; /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and com::sun::star::uno::XInterface which supports weak mechanism to be held weakly diff --git a/cppuhelper/inc/cppuhelper/implbase3.hxx b/cppuhelper/inc/cppuhelper/implbase3.hxx index 0ed901fd82f6..88eef99e45af 100644 --- a/cppuhelper/inc/cppuhelper/implbase3.hxx +++ b/cppuhelper/inc/cppuhelper/implbase3.hxx @@ -86,6 +86,9 @@ namespace cppu { return ImplHelper_getTypes( cd::get() ); } virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException) { return ImplHelper_getImplementationId( cd::get() ); } + + protected: + ~ImplHelper3() throw () {} }; /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and com::sun::star::uno::XInterface which supports weak mechanism to be held weakly diff --git a/cppuhelper/inc/cppuhelper/implbase4.hxx b/cppuhelper/inc/cppuhelper/implbase4.hxx index cbb33be94806..cb9660cb34aa 100644 --- a/cppuhelper/inc/cppuhelper/implbase4.hxx +++ b/cppuhelper/inc/cppuhelper/implbase4.hxx @@ -88,6 +88,9 @@ namespace cppu { return ImplHelper_getTypes( cd::get() ); } virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException) { return ImplHelper_getImplementationId( cd::get() ); } + + protected: + ~ImplHelper4() throw () {} }; /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and com::sun::star::uno::XInterface which supports weak mechanism to be held weakly diff --git a/cppuhelper/inc/cppuhelper/implbase5.hxx b/cppuhelper/inc/cppuhelper/implbase5.hxx index 86918f5b3c1a..71446a5ff72e 100644 --- a/cppuhelper/inc/cppuhelper/implbase5.hxx +++ b/cppuhelper/inc/cppuhelper/implbase5.hxx @@ -89,6 +89,9 @@ namespace cppu { return ImplHelper_getTypes( cd::get() ); } virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException) { return ImplHelper_getImplementationId( cd::get() ); } + + protected: + ~ImplHelper5() throw () {} }; /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and com::sun::star::uno::XInterface which supports weak mechanism to be held weakly diff --git a/cppuhelper/inc/cppuhelper/implbase6.hxx b/cppuhelper/inc/cppuhelper/implbase6.hxx index 3e8f5ef4ea6c..dca9d86ac2e6 100644 --- a/cppuhelper/inc/cppuhelper/implbase6.hxx +++ b/cppuhelper/inc/cppuhelper/implbase6.hxx @@ -90,6 +90,9 @@ namespace cppu { return ImplHelper_getTypes( cd::get() ); } virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException) { return ImplHelper_getImplementationId( cd::get() ); } + + protected: + ~ImplHelper6() throw () {} }; /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and com::sun::star::uno::XInterface which supports weak mechanism to be held weakly diff --git a/cppuhelper/inc/cppuhelper/implbase7.hxx b/cppuhelper/inc/cppuhelper/implbase7.hxx index b347127cdaf7..93115a38873f 100644 --- a/cppuhelper/inc/cppuhelper/implbase7.hxx +++ b/cppuhelper/inc/cppuhelper/implbase7.hxx @@ -91,6 +91,9 @@ namespace cppu { return ImplHelper_getTypes( cd::get() ); } virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException) { return ImplHelper_getImplementationId( cd::get() ); } + + protected: + ~ImplHelper7() throw () {} }; /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and com::sun::star::uno::XInterface which supports weak mechanism to be held weakly diff --git a/cppuhelper/inc/cppuhelper/implbase8.hxx b/cppuhelper/inc/cppuhelper/implbase8.hxx index 8c0aa4a180b3..e37c0c96e206 100644 --- a/cppuhelper/inc/cppuhelper/implbase8.hxx +++ b/cppuhelper/inc/cppuhelper/implbase8.hxx @@ -92,6 +92,9 @@ namespace cppu { return ImplHelper_getTypes( cd::get() ); } virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException) { return ImplHelper_getImplementationId( cd::get() ); } + + protected: + ~ImplHelper8() throw () {} }; /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and com::sun::star::uno::XInterface which supports weak mechanism to be held weakly diff --git a/cppuhelper/inc/cppuhelper/implbase9.hxx b/cppuhelper/inc/cppuhelper/implbase9.hxx index cf4f5bbd1e56..a09d79b0a681 100644 --- a/cppuhelper/inc/cppuhelper/implbase9.hxx +++ b/cppuhelper/inc/cppuhelper/implbase9.hxx @@ -93,6 +93,9 @@ namespace cppu { return ImplHelper_getTypes( cd::get() ); } virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException) { return ImplHelper_getImplementationId( cd::get() ); } + + protected: + ~ImplHelper9() throw () {} }; /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and com::sun::star::uno::XInterface which supports weak mechanism to be held weakly diff --git a/cppuhelper/inc/cppuhelper/propertysetmixin.hxx b/cppuhelper/inc/cppuhelper/propertysetmixin.hxx index 07d50c01225a..ca3b88214dd3 100644 --- a/cppuhelper/inc/cppuhelper/propertysetmixin.hxx +++ b/cppuhelper/inc/cppuhelper/propertysetmixin.hxx @@ -87,6 +87,10 @@ template< typename T > class PropertySetMixin; @since UDK 3.2.1 */ +#if defined __GNUC__ && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" +#endif class CPPUHELPER_DLLPUBLIC PropertySetMixinImpl: public com::sun::star::beans::XPropertySet, public com::sun::star::beans::XFastPropertySet, @@ -403,6 +407,9 @@ private: void checkUnknown(rtl::OUString const & propertyName); }; +#if defined __GNUC__ && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) +#pragma GCC diagnostic pop +#endif /** @short A helper mixin to implement certain UNO interfaces related to property diff --git a/cppuhelper/inc/cppuhelper/propshlp.hxx b/cppuhelper/inc/cppuhelper/propshlp.hxx index 1ed2f609e407..08dee8822941 100644 --- a/cppuhelper/inc/cppuhelper/propshlp.hxx +++ b/cppuhelper/inc/cppuhelper/propshlp.hxx @@ -334,6 +334,10 @@ public: sal_Int32 nCount, sal_Bool bVetoable, bool bIgnoreRuntimeExceptionsWhileFiring) = 0; + +protected: + ~IEventNotificationHook() {} + // avoid warnings about virtual members and non-virtual dtor }; @@ -656,11 +660,9 @@ private: sal_Int32 i_count ); -public: +protected: // Suppress warning about virtual functions but non-virtual destructor: -#if defined __GNUC__ -#pragma GCC system_header -#elif defined _MSC_VER +#if defined _MSC_VER #pragma warning(push) #pragma warning(disable: 4265) #endif @@ -703,7 +705,7 @@ private: OPropertySetHelper2( const OPropertySetHelper2 & ) SAL_THROW(()); OPropertySetHelper2 & operator = ( const OPropertySetHelper2 & ) SAL_THROW(()); -public: +protected: // Suppress warning about virtual functions but non-virtual destructor: /** You must call disposing before destruction. diff --git a/cppuhelper/source/exc_thrower.cxx b/cppuhelper/source/exc_thrower.cxx index 105adae891c6..37cccf99525f 100644 --- a/cppuhelper/source/exc_thrower.cxx +++ b/cppuhelper/source/exc_thrower.cxx @@ -57,6 +57,8 @@ struct ExceptionThrower : public uno_Interface, XExceptionThrower { inline ExceptionThrower(); + virtual ~ExceptionThrower() {} + static inline Type const & getCppuType() { return ::getCppuType( diff --git a/cppuhelper/unotypes/Makefile b/cppuhelper/unotypes/Makefile index fae02aeca501..c92ad45a9304 100644 --- a/cppuhelper/unotypes/Makefile +++ b/cppuhelper/unotypes/Makefile @@ -26,12 +26,12 @@ # instead of those above. gb_PARTIALBUILD:=T -include $(GBUILDDIR)/gbuild_simple.mk +include $(GBUILDDIR)/gbuild.mk all: private_types.flag unotypes.flag # private_types -private_types.flag: private_types.rdb +private_types.flag: private_types.rdb $(gb_UnoApiTarget_CPPUMAKERTARGET) $(call gb_Helper_abbreviate_dirs_native, \ $(call gb_Helper_execute,cppumaker) -O. -BUCR -C $< \ -Tcppuhelper.detail.XExceptionThrower \ @@ -48,10 +48,11 @@ XExceptionThrower.urd: $(SRCDIR)/cppuhelper/unotypes/cppuhelper/detail/XExceptio $(call gb_Helper_execute,idlc) -I. -I$(OUTDIR_FOR_BUILD)/idl -O. $<) # unotypes -unotypes.flag: +unotypes.flag: $(gb_UnoApiTarget_CPPUMAKERTARGET) $(call gb_Helper_abbreviate_dirs_native, \ $(call gb_Helper_execute,cppumaker) -O. -BUCR -C \ $(foreach type,$(UNOTYPES),-T$(type)) $(OUTDIR_FOR_BUILD)/bin/udkapi.rdb) + touch $@ UNOTYPES := \ com.sun.star.beans.PropertyAttribute \ -- cgit