From: Jonathan Wakely <jwakely@redhat.com>
To: JeanHeyd Meneide <phdofthehouse@gmail.com>
Cc: libstdc++ <libstdc++@gcc.gnu.org>, gcc-patches@gcc.gnu.org
Subject: Re: [ PATCH ] [ C++ ] Implementing P0767 - deprecate POD
Date: Thu, 09 Jan 2020 20:01:00 -0000 [thread overview]
Message-ID: <20200109195745.GY490107@redhat.com> (raw)
In-Reply-To: <CANHA4Ohe0zupZ94HHNobjMnUfp7NmBc9jbe8Fh2U-m5NYm47TA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 5696 bytes --]
On 04/12/19 17:56 -0500, JeanHeyd Meneide wrote:
>Dear Jonathan,
>
> Done! re-patched, below.
Thanks!
Some comments below.
>Best,
>JeanHeyd
>
>2019-12-03 JeanHeyd "ThePhD" Meneide <phdofthehouse@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
The parenthesis after the filename should tell you the entity that was
changed, so something like:
* 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.
This tells you that _GLIBCXX20_DEPRECATED is the new macro, and that
is_pod and is_pod_v were deprecated.
>diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
>index 7ccfc5f199d..9e85fc2c9e8 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(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 8e787a994c3..5980b21c763 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<T> is deprecated in C++20: use (is_standard_layout_v<T> && is_trivial_v<T>) 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_v<T> is deprecated in C++20: use (is_standard_layout_v<T> && is_trivial_v<T>) instead")
This message ends up repeating the "is deprecated":
pod.cc:6:21: warning: 'std::is_pod_v<A>' is deprecated: is_pod_v<T> is deprecated in C++20: use (is_standard_layout_v<T> && is_trivial_v<T>) instead [-Wdeprecated-declarations]
I think we can just shorten it to the "use ... instead". Also, given
that the compiler prints the template argument list "<A>" it's a bit
confusing to also put argument lists (with different types) in the
message. I think this is better:
pod.cc:6:21: warning: 'std::is_pod_v<A>' is deprecated: use is_standard_layout_v && is_trivial_v instead [-Wdeprecated-declarations]
> 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..1035a729434
>--- /dev/null
>+++ b/libstdc++-v3/testsuite/20_util/is_pod/deprecated-2a.cc
>@@ -0,0 +1,25 @@
>+// Copyright (C) 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 } }
This test doesn't actually run:
UNSUPPORTED: 20_util/is_pod/deprecated-2a.cc
It needs { dg-options "-std=gnu++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" }
I'll commit the attached patch after more testing.
N.B. it looks like the implementation of [[deprecated(msg)]] isn't
working quite right, because for is_pod I don't get the message:
pod.cc:6:21: warning: 'template<class _Tp> struct std::is_pod' is deprecated [-Wdeprecated-declarations]
6 | static_assert( std::is_pod<A>::value );
| ^~~~~~
In file included from pod.cc:1:
/home/jwakely/gcc/10/include/c++/10.0.0/type_traits:693:5: note: declared here
693 | is_pod
| ^~~~~~
It works correctly for std::is_pod_v.
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 3972 bytes --]
commit 2afe60862e34c76f096ca442bdf245f4c02e1612
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Jan 9 17:34:11 2020 +0000
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 <phdofthehouse@gmail.com>
* 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.
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<typename _Tp>
- struct is_pod
+ struct
+ _GLIBCXX20_DEPRECATED("use is_standard_layout && is_trivial instead")
+ is_pod
: public integral_constant<bool, __is_pod(_Tp)>
{
static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
@@ -3078,6 +3080,7 @@ template <typename _Tp>
template <typename _Tp>
inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value;
template <typename _Tp>
+ _GLIBCXX20_DEPRECATED("use is_standard_layout_v && is_trivial_v 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..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
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#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" }
+
+// { dg-prune-output "declared here" }
next prev parent reply other threads:[~2020-01-09 19:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-04 1:30 JeanHeyd Meneide
2019-12-04 21:47 ` Jonathan Wakely
2019-12-04 22:56 ` JeanHeyd Meneide
2020-01-09 20:01 ` Jonathan Wakely [this message]
2020-01-09 21:31 ` Jonathan Wakely
2020-01-10 13:55 ` Christophe Lyon
2020-01-10 15:21 ` Jonathan Wakely
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200109195745.GY490107@redhat.com \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
--cc=phdofthehouse@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).