From e26188145238572580b9af18fbde4b824b341046 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 29 Sep 2015 14:19:47 +0200 Subject: Avoid unhelpful -Wunused-variable ...at least from "g++ (GCC) 5.1.1 20150618 (Red Hat 5.1.1-4)" with --disable-debug, when a namespace-scope const variable with a "complex" initializer declared in an include file remains unused. Avoid that warning via SAL_CONSTEXPR, which in turn requires large parts of o3tl::is_typed_flags to be SAL_CONSTEXPR, which in turn requires a new HAVE_CXX14_CONSTEXPR to allow assert in constexpr functions, which in turn requires using -std=c++14 instead of -std=c++11 where available, which in turn (a) requires to /not/ use -std=c++14 if it would run into a bug between Clang and libstdc++ discussed at "llvm-nm fails to build with gcc 5.1's libstdc++" (and which hits us in sfx2/source/control/thumbnailview.cxx), and (b) requires a new HAVE_CXX14_SIZED_DEALLOCATION to work around GCC 5.1 -Werror=sized-deallocation (where Clang >= 3.7 only supports C++14 sized deallocation when explictly enabled via -fsized-deallocation, btw). This effectively reverts ff6462e6307e6924dc6c8178043ae9032f4b4152 "avoid unused variable warning:" again. Change-Id: I424e3561452a3e6d8c8a9604d6c737cab49840c4 Reviewed-on: https://gerrit.libreoffice.org/18918 Reviewed-by: Stephan Bergmann Tested-by: Stephan Bergmann --- sal/cpprt/operators_new_delete.cxx | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'sal') diff --git a/sal/cpprt/operators_new_delete.cxx b/sal/cpprt/operators_new_delete.cxx index 064caa5946f5..5fbd9c09be7d 100644 --- a/sal/cpprt/operators_new_delete.cxx +++ b/sal/cpprt/operators_new_delete.cxx @@ -18,8 +18,11 @@ */ #include +#include #include #include + +#include #include #include @@ -152,6 +155,20 @@ void SAL_CALL operator delete (void * p) throw () deallocate (p, ScalarTraits()); } +#if HAVE_CXX14_SIZED_DEALLOCATION +#if defined __clang__ +#pragma GCC diagnostic push // as happens on Mac OS X: +#pragma GCC diagnostic ignored "-Wimplicit-exception-spec-mismatch" +#endif +void SAL_CALL operator delete (void * p, std::size_t) noexcept +{ + deallocate (p, ScalarTraits()); +} +#if defined __clang__ +#pragma GCC diagnostic pop +#endif +#endif + // T * p = new(nothrow) T; delete(nothrow) p; void* SAL_CALL operator new (std::size_t n, std::nothrow_t const &) throw () @@ -176,6 +193,20 @@ void SAL_CALL operator delete[] (void * p) throw () deallocate (p, VectorTraits()); } +#if HAVE_CXX14_SIZED_DEALLOCATION +#if defined __clang__ +#pragma GCC diagnostic push // as happens on Mac OS X: +#pragma GCC diagnostic ignored "-Wimplicit-exception-spec-mismatch" +#endif +void SAL_CALL operator delete[] (void * p, std::size_t) noexcept +{ + deallocate (p, VectorTraits()); +} +#if defined __clang__ +#pragma GCC diagnostic pop +#endif +#endif + // T * p = new(nothrow) T[n]; delete(nothrow)[] p; void* SAL_CALL operator new[] (std::size_t n, std::nothrow_t const &) throw () -- cgit