From 1a6c5064f920adec998932f66955c74fbfd1fa09 Mon Sep 17 00:00:00 2001 From: "JeanHeyd \"ThePhD\" Meneide" Date: Thu, 9 Jan 2020 21:31:43 +0000 Subject: [PATCH] libstdc++: Implementing P0767 - deprecate POD This adds the deprecated attribute to std::is_pod and std::is_pod_v for C++20. 2019-12-05 JeanHeyd "ThePhD" Meneide * include/bits/c++config (_GLIBCXX20_DEPRECATED): Add new macro. * include/std/type_traits (is_pod, is_pod_v): Deprecate for C++20. * testuite/20_util/is_pod/deprecated-2a.cc: New test. From-SVN: r280065 --- libstdc++-v3/ChangeLog | 6 +++++ libstdc++-v3/include/bits/c++config | 7 +++++ libstdc++-v3/include/std/type_traits | 7 +++-- .../testsuite/20_util/is_pod/deprecated-2a.cc | 26 +++++++++++++++++++ 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 libstdc++-v3/testsuite/20_util/is_pod/deprecated-2a.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index c4a98f809d0..5725771bada 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +2020-01-09 JeanHeyd "ThePhD" Meneide + + * include/bits/c++config (_GLIBCXX20_DEPRECATED): Add new macro. + * include/std/type_traits (is_pod, is_pod_v): Deprecate for C++20. + * testuite/20_util/is_pod/deprecated-2a.cc: New test. + 2020-01-09 Jonathan Wakely PR libstdc++/93205 diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config index f983743b052..875a5e76890 100644 --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -78,6 +78,7 @@ // _GLIBCXX_USE_DEPRECATED // _GLIBCXX_DEPRECATED // _GLIBCXX17_DEPRECATED +// _GLIBCXX20_DEPRECATED( string-literal ) #ifndef _GLIBCXX_USE_DEPRECATED # define _GLIBCXX_USE_DEPRECATED 1 #endif @@ -94,6 +95,12 @@ # define _GLIBCXX17_DEPRECATED #endif +#if defined(__DEPRECATED) && (__cplusplus > 201703L) +# define _GLIBCXX20_DEPRECATED(MSG) [[deprecated(MSG)]] +#else +# define _GLIBCXX20_DEPRECATED(MSG) +#endif + // Macros for ABI tag attributes. #ifndef _GLIBCXX_ABI_TAG_CXX11 # define _GLIBCXX_ABI_TAG_CXX11 __attribute ((__abi_tag__ ("cxx11"))) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 061835b8f2d..c69867c2ae0 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -685,10 +685,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION "template argument must be a complete class or an unbounded array"); }; - /// is_pod + /// is_pod (deprecated in C++20) // Could use is_standard_layout && is_trivial instead of the builtin. template - struct is_pod + struct + _GLIBCXX20_DEPRECATED("use is_standard_layout && is_trivial instead") + is_pod : public integral_constant { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), @@ -3078,6 +3080,7 @@ template template inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value; template + _GLIBCXX20_DEPRECATED("use is_standard_layout_v && is_trivial_v instead") inline constexpr bool is_pod_v = is_pod<_Tp>::value; template inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value; diff --git a/libstdc++-v3/testsuite/20_util/is_pod/deprecated-2a.cc b/libstdc++-v3/testsuite/20_util/is_pod/deprecated-2a.cc new file mode 100644 index 00000000000..848baf7bcfe --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_pod/deprecated-2a.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include + +static_assert(std::is_pod::value); // { dg-warning "is deprecated" } +static_assert(std::is_pod_v); // { dg-warning "is deprecated" } + +// { dg-prune-output "declared here" } -- 2.30.2