This patch implements deprecate POD for the C++ Standard Library,
bringing libstdc++ that much closer to 2020 conformance 🎉!

Hilariously, a small bug in the [[deprecated]] warning message was
found while implementing this patch, which drove me a bit insane for a
good 10 minutes until I realized what was going on:
https://godbolt.org/z/WwBNUx

Either way, here you go! Someone will probably have to fix the
template-class [[deprecated("foo")]] bug at some point too.

2019-12-03  JeanHeyd "ThePhD" Meneide  <phdoftheho...@gmail.com>

        * include/bits/c++config: Add new _GLIBCXX20_DEPRECATED macro.
        * include/std/type_traits: Deprecate is_pod with message.
        * testuite/20_util/is_pod/deprecated-2a.cc (new): test deprecation
diff --git a/libstdc++-v3/include/bits/c++config 
b/libstdc++-v3/include/bits/c++config
index 7ccfc5f199d..5876b0b977b 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( STRINGS... )
 #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(...) [[deprecated(__VA_ARGS__)]]
+#else
+# define _GLIBCXX20_DEPRECATED(...) 
+#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 8e787a994c3..91269d1bd02 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 C++2a)
   // Could use is_standard_layout && is_trivial instead of the builtin.
   template<typename _Tp>
-    struct is_pod
+    struct
+    _GLIBCXX20_DEPRECATED("is_pod<Type> is deprecated in C++20: use 
is_standard_layout<Type> && is_trivial<Type> instead") 
+    is_pod
     : public integral_constant<bool, __is_pod(_Tp)>
     {
       static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
@@ -3073,6 +3075,7 @@ template <typename _Tp>
 template <typename _Tp>
   inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value;
 template <typename _Tp>
+  _GLIBCXX20_DEPRECATED("is_pod<Type> is deprecated in C++20: use 
is_standard_layout<Type> && is_trivial<Type> instead")
   inline constexpr bool is_pod_v = is_pod<_Tp>::value;
 template <typename _Tp>
   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..9782c3f551d
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/is_pod/deprecated-2a.cc
@@ -0,0 +1,25 @@
+// Copyright (C) 2010-2019 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
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do compile { target c++2a } }
+
+// { dg-prune-output "declared here" }
+
+#include <type_traits>
+
+static_assert(std::is_pod<int>::value); // { dg-warning "is deprecated" }
+static_assert(std::is_pod_v<int>); // { dg-warning "is deprecated" }

Reply via email to