Skip to content

Conversation

frederick-vs-ja
Copy link
Contributor

@frederick-vs-ja frederick-vs-ja commented Mar 3, 2025

Previously, commit 042f07e claimed that P0767R1 was implemented in LLVM 7.0, but no deprecation warning was implemented. This patch adds the missing warnings.

@frederick-vs-ja frederick-vs-ja requested a review from a team as a code owner March 3, 2025 03:30
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Mar 3, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 3, 2025

@llvm/pr-subscribers-libcxx

Author: A. Jiang (frederick-vs-ja)

Changes

Previously, commit 042f07e claimed that P0767R1 was implemented in LLVM 7.0, but no deprecation warning was implemented. This patch adds the missing warnings.


Full diff: https://github.com/llvm/llvm-project/pull/129471.diff

5 Files Affected:

  • (modified) libcxx/docs/ReleaseNotes/21.rst (+2)
  • (modified) libcxx/include/__type_traits/is_pod.h (+3-2)
  • (modified) libcxx/include/type_traits (+2-2)
  • (added) libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.deprecated.verify.cpp (+18)
  • (modified) libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp (+2)
diff --git a/libcxx/docs/ReleaseNotes/21.rst b/libcxx/docs/ReleaseNotes/21.rst
index e7cfa625a132c..a8d15a0f2f898 100644
--- a/libcxx/docs/ReleaseNotes/21.rst
+++ b/libcxx/docs/ReleaseNotes/21.rst
@@ -55,6 +55,8 @@ Improvements and New Features
 Deprecations and Removals
 -------------------------
 
+- ``std::is_pod`` and ``std::is_pod_v`` are deprecated since C++20 according to the standard.
+
 Upcoming Deprecations and Removals
 ----------------------------------
 
diff --git a/libcxx/include/__type_traits/is_pod.h b/libcxx/include/__type_traits/is_pod.h
index a57662400394a..b6aacf3b2b202 100644
--- a/libcxx/include/__type_traits/is_pod.h
+++ b/libcxx/include/__type_traits/is_pod.h
@@ -19,11 +19,12 @@
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_pod : public integral_constant<bool, __is_pod(_Tp)> {};
+struct _LIBCPP_TEMPLATE_VIS
+_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_NO_SPECIALIZATIONS is_pod : public integral_constant<bool, __is_pod(_Tp)> {};
 
 #if _LIBCPP_STD_VER >= 17
 template <class _Tp>
-_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_pod_v = __is_pod(_Tp);
+_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_pod_v = __is_pod(_Tp);
 #endif
 
 _LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits
index ffcddb0176615..772e4cb876469 100644
--- a/libcxx/include/type_traits
+++ b/libcxx/include/type_traits
@@ -95,8 +95,8 @@ namespace std
     template <class T> struct is_unbounded_array;               // C++20
 
     // Member introspection:
-    template <class T> struct is_pod;
     template <class T> struct is_trivial;
+    template <class T> struct is_pod;          // Deprecated in C++20
     template <class T> struct is_trivially_copyable;
     template <class T> struct is_standard_layout;
     template <class T> struct is_literal_type; // Deprecated in C++17; removed in C++20
@@ -303,7 +303,7 @@ namespace std
       template <class T> inline constexpr bool is_standard_layout_v
         = is_standard_layout<T>::value;                                  // C++17
       template <class T> inline constexpr bool is_pod_v
-        = is_pod<T>::value;                                              // C++17
+        = is_pod<T>::value;                                              // C++17; deprecated in C++20
       template <class T> inline constexpr bool is_literal_type_v
         = is_literal_type<T>::value;                                     // C++17; deprecated in C++17; removed in C++20
       template <class T> inline constexpr bool is_empty_v
diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.deprecated.verify.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.deprecated.verify.cpp
new file mode 100644
index 0000000000000..df8ce7bfb9ac2
--- /dev/null
+++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.deprecated.verify.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: std-at-least-c++20
+
+// <type_traits>
+
+// is_pod and is_pod_v are deprecated in C++20 by P0767R1
+
+#include <type_traits>
+
+static_assert(std::is_pod<int>::value); // expected-warning {{'is_pod<int>' is deprecated}}
+static_assert(std::is_pod_v<int>); // expected-warning {{'is_pod_v<int>' is deprecated}}
diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp
index 87fe6ebbee883..887033fc72d86 100644
--- a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp
+++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp
@@ -10,6 +10,8 @@
 
 // is_pod
 
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
+
 #include <type_traits>
 #include "test_macros.h"
 

Copy link

github-actions bot commented Mar 3, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

Previously, commit 042f07e claimed that
P0767R1 was implemented in LLVM 7.0, but no deprecation warning was
implemented. This patch adds the missing warnings.
@frederick-vs-ja
Copy link
Contributor Author

frederick-vs-ja commented Mar 3, 2025

The entry for P0767R1 in Cxx20Papers.csv looks quite superfluous. Should we also change it?

"`P0767R1 <https://wg21.link/P0767R1>`__","Deprecate POD","2017-11 (Albuquerque)","|Complete|","7",""

@mordante mordante self-assigned this Mar 3, 2025
Copy link
Member

@mordante mordante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this!

Copy link
Member

@mordante mordante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I've some requests.

- aligning all version comments to line 65,
- using `// since C++` instead of `// C++`, in lowercase as used in most version comments,
- changing the comments for `bool_constant` to `// since C++17` as it's a C++17 feature,
- changing the class-key of `result_of` to `struct`, which follows N4659 [depr.meta.types] and the actual usage in libc++,
- consistently using `class` to introduce type template parameters,
- consistently using `inline constexpr` for variable templates,
- moving the comments for `is_nothrow_convertible_v` to the part for variable templates, and
- removing duplicated comments for `true_type` and `false_type`.
@frederick-vs-ja frederick-vs-ja merged commit 94714fb into llvm:main Mar 7, 2025
87 checks passed
@frederick-vs-ja frederick-vs-ja deleted the deprecate-is_pod branch March 8, 2025 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants