public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [ PATCH ] [ C++ ] Implementing P0767 - deprecate POD
@ 2019-12-04  1:30 JeanHeyd Meneide
  2019-12-04 21:47 ` Jonathan Wakely
  0 siblings, 1 reply; 7+ messages in thread
From: JeanHeyd Meneide @ 2019-12-04  1:30 UTC (permalink / raw)
  To: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 767 bytes --]

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  <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

[-- Attachment #2: is_pod.deprecate.patch.txt --]
[-- Type: text/plain, Size: 3365 bytes --]

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" }

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [ PATCH ] [ C++ ] Implementing P0767 - deprecate POD
  2019-12-04  1:30 [ PATCH ] [ C++ ] Implementing P0767 - deprecate POD JeanHeyd Meneide
@ 2019-12-04 21:47 ` Jonathan Wakely
  2019-12-04 22:56   ` JeanHeyd Meneide
  0 siblings, 1 reply; 7+ messages in thread
From: Jonathan Wakely @ 2019-12-04 21:47 UTC (permalink / raw)
  To: JeanHeyd Meneide; +Cc: libstdc++, gcc-patches

On 03/12/19 20:30 -0500, JeanHeyd Meneide wrote:
>This patch implements deprecate POD for the C++ Standard Library,

Thanks.

>bringing libstdc++ that much closer to 2020 conformance 🎉!

N.B. adding the attribute is not required for conformance.

>+#if defined(__DEPRECATED) && (__cplusplus > 201703L)
>+# define _GLIBCXX20_DEPRECATED(...) [[deprecated(__VA_ARGS__)]]

Does this need to us __VA_ARGS__? Won't it always be a single
preprocessor token, specifically, a string literal?

>+#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")

That isn't a valid expression, it should probably say:

"use is_standard_layout_v<Type> && is_trivial_v<Type> instead"

i.e. recommend the variable templates.

I think I'd prefer "T" rather than "Type".

>+// Copyright (C) 2010-2019 Free Software Foundation, Inc.

Just 2019 for the date. It's a new file.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [ PATCH ] [ C++ ] Implementing P0767 - deprecate POD
  2019-12-04 21:47 ` Jonathan Wakely
@ 2019-12-04 22:56   ` JeanHeyd Meneide
  2020-01-09 20:01     ` Jonathan Wakely
  0 siblings, 1 reply; 7+ messages in thread
From: JeanHeyd Meneide @ 2019-12-04 22:56 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 340 bytes --]

Dear Jonathan,

    Done! re-patched, 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

[-- Attachment #2: is_pod.deprecated.patch.txt --]
[-- Type: text/plain, Size: 3348 bytes --]

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")
   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 } }
+
+// { 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" }

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [ PATCH ] [ C++ ] Implementing P0767 - deprecate POD
  2019-12-04 22:56   ` JeanHeyd Meneide
@ 2020-01-09 20:01     ` Jonathan Wakely
  2020-01-09 21:31       ` Jonathan Wakely
  0 siblings, 1 reply; 7+ messages in thread
From: Jonathan Wakely @ 2020-01-09 20:01 UTC (permalink / raw)
  To: JeanHeyd Meneide; +Cc: libstdc++, gcc-patches

[-- 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" }

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [ PATCH ] [ C++ ] Implementing P0767 - deprecate POD
  2020-01-09 20:01     ` Jonathan Wakely
@ 2020-01-09 21:31       ` Jonathan Wakely
  2020-01-10 13:55         ` Christophe Lyon
  0 siblings, 1 reply; 7+ messages in thread
From: Jonathan Wakely @ 2020-01-09 21:31 UTC (permalink / raw)
  To: JeanHeyd Meneide; +Cc: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 149 bytes --]

On 09/01/20 19:57 +0000, Jonathan Wakely wrote:
>I'll commit the attached patch after more testing.

And this follow-up to fix some fallout.



[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 5386 bytes --]

commit 212e166cbeb4c7df38436563c3c51dbd4e0efc0d
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Jan 9 19:55:17 2020 +0000

    libstdc++: Fix testsuite failures and warnings due to is_pod deprecation
    
    With -std=gnu++2a and -Wsystem-headers the std::is_pod deprecation
    causes some new diagnostics. This suppresses them.
    
            * include/experimental/type_traits (experimental::is_pod_v): Disable
            -Wdeprecated-declarations warnings around reference to std::is_pod.
            * include/std/type_traits (is_pod_v): Likewise.
            * testsuite/18_support/max_align_t/requirements/2.cc: Also check
            is_standard_layout and is_trivial. Do not check is_pod for C++20.
            * testsuite/20_util/is_pod/requirements/explicit_instantiation.cc:
            Add -Wno-deprecated for C++20.
            * testsuite/20_util/is_pod/requirements/typedefs.cc: Likewise.
            * testsuite/20_util/is_pod/value.cc: Likewise.
            * testsuite/experimental/type_traits/value.cc: Likewise.

diff --git a/libstdc++-v3/include/experimental/type_traits b/libstdc++-v3/include/experimental/type_traits
index a84ddd45ff1..a92c385c029 100644
--- a/libstdc++-v3/include/experimental/type_traits
+++ b/libstdc++-v3/include/experimental/type_traits
@@ -110,8 +110,11 @@ template <typename _Tp>
   constexpr bool is_trivially_copyable_v = is_trivially_copyable<_Tp>::value;
 template <typename _Tp>
   constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 template <typename _Tp>
   constexpr bool is_pod_v = is_pod<_Tp>::value;
+#pragma GCC diagnostic pop
 template <typename _Tp>
   constexpr bool is_literal_type_v = is_literal_type<_Tp>::value;
 template <typename _Tp>
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index c69867c2ae0..6aa2cedfa0a 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -3079,9 +3079,12 @@ template <typename _Tp>
     is_trivially_copyable<_Tp>::value;
 template <typename _Tp>
   inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 template <typename _Tp>
   _GLIBCXX20_DEPRECATED("use is_standard_layout_v && is_trivial_v instead")
   inline constexpr bool is_pod_v = is_pod<_Tp>::value;
+#pragma GCC diagnostic pop
 template <typename _Tp>
   inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value;
 template <typename _Tp>
diff --git a/libstdc++-v3/testsuite/18_support/max_align_t/requirements/2.cc b/libstdc++-v3/testsuite/18_support/max_align_t/requirements/2.cc
index 97036ed3134..7e496967156 100644
--- a/libstdc++-v3/testsuite/18_support/max_align_t/requirements/2.cc
+++ b/libstdc++-v3/testsuite/18_support/max_align_t/requirements/2.cc
@@ -20,4 +20,8 @@
 #include <cstddef>
 #include <type_traits>
 
+#if __cplusplus <= 201703L
 static_assert (std::is_pod<std::max_align_t>::value, "");
+#endif
+static_assert (std::is_standard_layout<std::max_align_t>::value, "");
+static_assert (std::is_trivial<std::max_align_t>::value, "");
diff --git a/libstdc++-v3/testsuite/20_util/is_pod/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_pod/requirements/explicit_instantiation.cc
index 7ee41b33d7c..b41a59338bb 100644
--- a/libstdc++-v3/testsuite/20_util/is_pod/requirements/explicit_instantiation.cc
+++ b/libstdc++-v3/testsuite/20_util/is_pod/requirements/explicit_instantiation.cc
@@ -1,4 +1,5 @@
 // { dg-do compile { target c++11 } }
+// { dg-additional-options "-Wno-deprecated" { target { c++2a } } }
 // 2010-02-21  Paolo Carlini  <paolo.carlini@oracle.com>
 
 // Copyright (C) 2010-2020 Free Software Foundation, Inc.
diff --git a/libstdc++-v3/testsuite/20_util/is_pod/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_pod/requirements/typedefs.cc
index 492f0ea956f..888895719b7 100644
--- a/libstdc++-v3/testsuite/20_util/is_pod/requirements/typedefs.cc
+++ b/libstdc++-v3/testsuite/20_util/is_pod/requirements/typedefs.cc
@@ -1,4 +1,5 @@
 // { dg-do compile { target c++11 } }
+// { dg-additional-options "-Wno-deprecated" { target { c++2a } } }
 
 // 2010-02-21  Paolo Carlini  <paolo.carlini@oracle.com>
 //
diff --git a/libstdc++-v3/testsuite/20_util/is_pod/value.cc b/libstdc++-v3/testsuite/20_util/is_pod/value.cc
index 5a856309ad5..659d9d4d8ae 100644
--- a/libstdc++-v3/testsuite/20_util/is_pod/value.cc
+++ b/libstdc++-v3/testsuite/20_util/is_pod/value.cc
@@ -1,4 +1,5 @@
 // { dg-do compile { target c++11 } }
+// { dg-additional-options "-Wno-deprecated" { target { c++2a } } }
 
 // 2010-02-21  Paolo Carlini  <pcarlini@suse.de>
 //
diff --git a/libstdc++-v3/testsuite/experimental/type_traits/value.cc b/libstdc++-v3/testsuite/experimental/type_traits/value.cc
index 156753b4b5e..0e1176dd14a 100644
--- a/libstdc++-v3/testsuite/experimental/type_traits/value.cc
+++ b/libstdc++-v3/testsuite/experimental/type_traits/value.cc
@@ -1,4 +1,5 @@
 // { dg-do compile { target c++14 } }
+// { dg-additional-options "-Wno-deprecated" { target { c++2a } } }
 
 // Copyright (C) 2014-2020 Free Software Foundation, Inc.
 //

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [ PATCH ] [ C++ ] Implementing P0767 - deprecate POD
  2020-01-09 21:31       ` Jonathan Wakely
@ 2020-01-10 13:55         ` Christophe Lyon
  2020-01-10 15:21           ` Jonathan Wakely
  0 siblings, 1 reply; 7+ messages in thread
From: Christophe Lyon @ 2020-01-10 13:55 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: JeanHeyd Meneide, libstdc++, gcc Patches

Hi,

On Thu, 9 Jan 2020 at 22:21, Jonathan Wakely <jwakely@redhat.com> wrote:
>
> On 09/01/20 19:57 +0000, Jonathan Wakely wrote:
> >I'll commit the attached patch after more testing.
>
> And this follow-up to fix some fallout.
>

I have noticed:
FAIL: g++:g++.dg/cpp0x/std-layout1.C  -std=c++2a (test for excess errors)

was that follow-up intended to fix this too?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [ PATCH ] [ C++ ] Implementing P0767 - deprecate POD
  2020-01-10 13:55         ` Christophe Lyon
@ 2020-01-10 15:21           ` Jonathan Wakely
  0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Wakely @ 2020-01-10 15:21 UTC (permalink / raw)
  To: Christophe Lyon; +Cc: JeanHeyd Meneide, libstdc++, gcc Patches, Jason Merrill

[-- Attachment #1: Type: text/plain, Size: 529 bytes --]

On 10/01/20 13:25 +0100, Christophe Lyon wrote:
>Hi,
>
>On Thu, 9 Jan 2020 at 22:21, Jonathan Wakely <jwakely@redhat.com> wrote:
>>
>> On 09/01/20 19:57 +0000, Jonathan Wakely wrote:
>> >I'll commit the attached patch after more testing.
>>
>> And this follow-up to fix some fallout.
>>
>
>I have noticed:
>FAIL: g++:g++.dg/cpp0x/std-layout1.C  -std=c++2a (test for excess errors)
>
>was that follow-up intended to fix this too?

No, I didn't touch the gcc tests.

This fixes it.

Jason, OK for trunk?




[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 816 bytes --]

commit ffee4a19afa0f3c78378c1db9d5170d2feb156b6
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Jan 10 13:04:09 2020 +0000

    Fix g++ testsuite failure caused by std::is_pod deprecation
    
            * g++.dg/cpp0x/std-layout1.C: Use -Wno-deprecated-declarations for
            C++20, due to std::is_pod being deprecated.

diff --git a/gcc/testsuite/g++.dg/cpp0x/std-layout1.C b/gcc/testsuite/g++.dg/cpp0x/std-layout1.C
index 09273c5f1c6..36ae170afcb 100644
--- a/gcc/testsuite/g++.dg/cpp0x/std-layout1.C
+++ b/gcc/testsuite/g++.dg/cpp0x/std-layout1.C
@@ -1,4 +1,5 @@
 // { dg-do compile { target c++11 } }
+// { dg-additional-options "-Wno-deprecated-declarations" { target c++2a } }
 
 // [basic.types]/10:
 // Scalar types, standard-layout class types (Clause 9), arrays of such

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-01-10 13:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-04  1:30 [ PATCH ] [ C++ ] Implementing P0767 - deprecate POD JeanHeyd Meneide
2019-12-04 21:47 ` Jonathan Wakely
2019-12-04 22:56   ` JeanHeyd Meneide
2020-01-09 20:01     ` Jonathan Wakely
2020-01-09 21:31       ` Jonathan Wakely
2020-01-10 13:55         ` Christophe Lyon
2020-01-10 15:21           ` Jonathan Wakely

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).