From a973490f538be00000e196819bb21acdde60ccd9 Mon Sep 17 00:00:00 2001 From: Braden Ganetsky Date: Sun, 17 Mar 2024 20:12:06 -0500 Subject: [PATCH] Fix deprecated warning ignores in allocator_access.hpp, and add compile test for pmr allocator --- include/boost/core/allocator_access.hpp | 26 +++++++++++++++++++------ test/Jamfile.v2 | 1 + test/allocator_pmr_test.cpp | 22 +++++++++++++++++++++ 3 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 test/allocator_pmr_test.cpp diff --git a/include/boost/core/allocator_access.hpp b/include/boost/core/allocator_access.hpp index 8e33ebb..0f0ed32 100644 --- a/include/boost/core/allocator_access.hpp +++ b/include/boost/core/allocator_access.hpp @@ -43,9 +43,17 @@ _LIBCPP_SUPPRESS_DEPRECATED_PUSH #if defined(_STL_DISABLE_DEPRECATED_WARNING) _STL_DISABLE_DEPRECATED_WARNING #endif -#if defined(_MSC_VER) -#pragma warning(push) -#pragma warning(disable:4996) +#if defined(__clang__) && defined(__has_warning) +# if __has_warning("-Wdeprecated-declarations") +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdeprecated-declarations" +# endif +#elif defined(_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) +#elif defined(BOOST_GCC) && BOOST_GCC >= 40600 +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif namespace boost { @@ -807,9 +815,15 @@ using allocator_rebind_t = typename allocator_rebind::type; } /* boost */ -#if defined(_MSC_VER) -#pragma warning(pop) -#endif +#if defined(__clang__) && defined(__has_warning) +# if __has_warning("-Wdeprecated-declarations") +# pragma clang diagnostic pop +# endif +#elif defined(_MSC_VER) +# pragma warning(pop) +#elif defined(BOOST_GCC) && BOOST_GCC >= 40600 +# pragma GCC diagnostic pop +#endif #if defined(_STL_RESTORE_DEPRECATED_WARNING) _STL_RESTORE_DEPRECATED_WARNING #endif diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 2bc6a4b..0051ec2 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -265,6 +265,7 @@ run allocator_destroy_test.cpp ; run allocator_construct_n_test.cpp ; run allocator_destroy_n_test.cpp ; run allocator_traits_test.cpp ; +compile allocator_pmr_test.cpp ; lib lib_typeid : lib_typeid.cpp : shared:LIB_TYPEID_DYN_LINK=1 ; diff --git a/test/allocator_pmr_test.cpp b/test/allocator_pmr_test.cpp new file mode 100644 index 0000000..96def03 --- /dev/null +++ b/test/allocator_pmr_test.cpp @@ -0,0 +1,22 @@ +// +// Testing stdlib polymorphic allocators +// +// Copyright 2024 Braden Ganetsky +// +// Distributed under the Boost Software License, Version 1.0. +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt +// + +#include +#include + +#ifndef BOOST_NO_CXX17_HDR_MEMORY_RESOURCE +#include + +void pmr_allocator_destroy_compiles(std::pmr::polymorphic_allocator& alloc, int* p) +{ + boost::allocator_destroy(alloc, p); +} + +#endif // !defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)