public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] libstdc++: Add deprecated attributes to old iostream members
@ 2020-08-19 11:29 Jonathan Wakely
  2020-08-19 12:47 ` Jonathan Wakely
  2020-08-19 13:53 ` Jonathan Wakely
  0 siblings, 2 replies; 3+ messages in thread
From: Jonathan Wakely @ 2020-08-19 11:29 UTC (permalink / raw)
  To: libstdc++, gcc-patches

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

Back in 2017 I removed these prehistoric members (which were deprecated
since C++98) for C++17 mode. But I didn't add deprecated attributes to
most of them, so users didn't get any warning they would be going away.
Apparently some poor souls do actually use some of these names, and so
now that GCC 11 defaults to -std=gnu++17 some code has stopped
compiling.

This adds deprecated attributes to them, so that C++98/03/11/14 code
will get a warning if it uses them. I'll also backport this to the
release branches so that users can find out about the deprecation before
they start using C++17.

In order to give deprecated warnings even in C++98 mode this patch makes
_GLIBCXX_DEPRECATED work even for C++98, adds _GLIBCXX11_DEPRECATED for
the old meaning of _GLIBCXX_DEPRECATED, and adds new macros such as
_GLIBCXX_DEPRECATED_SUGGEST for suggesting alternatives to deprecated
features.

libstdc++-v3/ChangeLog:

	* include/bits/c++config (_GLIBCXX_DEPRECATED): Define for all
	standard modes.
	(_GLIBCXX_DEPRECATED_SUGGEST): New macro for "use 'foo' instead"
	message in deprecated warnings.
	(_GLIBCXX11_DEPRECATED, _GLIBCXX11_DEPRECATED_SUGGEST): New
	macros for marking features derpecated in C++11.
	(_GLIBCXX17_DEPRECATED_SUGGEST, _GLIBCXX20_DEPRECATED_SUGGEST):
	New macros.
	* include/backward/auto_ptr.h (auto_ptr_ref, auto_ptr<void>):
	Use _GLIBCXX11_DEPRECATED instead of _GLIBCXX_DEPRECATED.
	(auto_ptr): Use _GLIBCXX11_DEPRECATED_SUGGEST.
	* include/backward/binders.h (binder1st, binder2nd): Likewise.
	* include/bits/ios_base.h (io_state, open_mode, seek_dir)
	(streampos, streamoff): Use _GLIBCXX_DEPRECATED_SUGGEST.
	* include/std/streambuf (stossc): Replace C++11 attribute
	with _GLIBCXX_DEPRECATED_SUGGEST.
	* include/std/type_traits (__is_nullptr_t): Use
	_GLIBCXX_DEPRECATED_SUGGEST instead of _GLIBCXX_DEPRECATED.
	* testsuite/27_io/types/1.cc: Check for deprecated warnings.
	Also check for io_state, open_mode and seek_dir typedefs.

Tested powerpc64le-linux. Committed to trunk.


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

commit eef9bf4ca8d90a1751bc4bff03722ee68999eb8e
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Aug 19 12:13:03 2020

    libstdc++: Add deprecated attributes to old iostream members
    
    Back in 2017 I removed these prehistoric members (which were deprecated
    since C++98) for C++17 mode. But I didn't add deprecated attributes to
    most of them, so users didn't get any warning they would be going away.
    Apparently some poor souls do actually use some of these names, and so
    now that GCC 11 defaults to -std=gnu++17 some code has stopped
    compiling.
    
    This adds deprecated attributes to them, so that C++98/03/11/14 code
    will get a warning if it uses them. I'll also backport this to the
    release branches so that users can find out about the deprecation before
    they start using C++17.
    
    In order to give deprecated warnings even in C++98 mode this patch makes
    _GLIBCXX_DEPRECATED work even for C++98, adds _GLIBCXX11_DEPRECATED for
    the old meaning of _GLIBCXX_DEPRECATED, and adds new macros such as
    _GLIBCXX_DEPRECATED_SUGGEST for suggesting alternatives to deprecated
    features.
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/c++config (_GLIBCXX_DEPRECATED): Define for all
            standard modes.
            (_GLIBCXX_DEPRECATED_SUGGEST): New macro for "use 'foo' instead"
            message in deprecated warnings.
            (_GLIBCXX11_DEPRECATED, _GLIBCXX11_DEPRECATED_SUGGEST): New
            macros for marking features derpecated in C++11.
            (_GLIBCXX17_DEPRECATED_SUGGEST, _GLIBCXX20_DEPRECATED_SUGGEST):
            New macros.
            * include/backward/auto_ptr.h (auto_ptr_ref, auto_ptr<void>):
            Use _GLIBCXX11_DEPRECATED instead of _GLIBCXX_DEPRECATED.
            (auto_ptr): Use _GLIBCXX11_DEPRECATED_SUGGEST.
            * include/backward/binders.h (binder1st, binder2nd): Likewise.
            * include/bits/ios_base.h (io_state, open_mode, seek_dir)
            (streampos, streamoff): Use _GLIBCXX_DEPRECATED_SUGGEST.
            * include/std/streambuf (stossc): Replace C++11 attribute
            with _GLIBCXX_DEPRECATED_SUGGEST.
            * include/std/type_traits (__is_nullptr_t): Use
            _GLIBCXX_DEPRECATED_SUGGEST instead of _GLIBCXX_DEPRECATED.
            * testsuite/27_io/types/1.cc: Check for deprecated warnings.
            Also check for io_state, open_mode and seek_dir typedefs.

diff --git a/libstdc++-v3/include/backward/auto_ptr.h b/libstdc++-v3/include/backward/auto_ptr.h
index 85116364cd2..0863a0804d1 100644
--- a/libstdc++-v3/include/backward/auto_ptr.h
+++ b/libstdc++-v3/include/backward/auto_ptr.h
@@ -51,7 +51,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       
       explicit
       auto_ptr_ref(_Tp1* __p): _M_ptr(__p) { }
-    } _GLIBCXX_DEPRECATED;
+    } _GLIBCXX11_DEPRECATED;
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
@@ -284,7 +284,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       template<typename _Tp1>
         operator auto_ptr<_Tp1>() throw()
         { return auto_ptr<_Tp1>(this->release()); }
-    } _GLIBCXX_DEPRECATED;
+    } _GLIBCXX11_DEPRECATED_SUGGEST("std::unique_ptr");
 
   // _GLIBCXX_RESOLVE_LIB_DEFECTS
   // 541. shared_ptr template assignment and void
@@ -293,7 +293,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     {
     public:
       typedef void element_type;
-    } _GLIBCXX_DEPRECATED;
+    } _GLIBCXX11_DEPRECATED;
 
 #if __cplusplus >= 201103L
   template<_Lock_policy _Lp>
diff --git a/libstdc++-v3/include/backward/binders.h b/libstdc++-v3/include/backward/binders.h
index 8c2c00d784b..e3029e74bf1 100644
--- a/libstdc++-v3/include/backward/binders.h
+++ b/libstdc++-v3/include/backward/binders.h
@@ -127,7 +127,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       typename _Operation::result_type
       operator()(typename _Operation::second_argument_type& __x) const
       { return op(value, __x); }
-    } _GLIBCXX_DEPRECATED;
+    } _GLIBCXX11_DEPRECATED_SUGGEST("std::bind");
 
   /// One of the @link binders binder functors@endlink.
   template<typename _Operation, typename _Tp>
@@ -162,7 +162,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       typename _Operation::result_type
       operator()(typename _Operation::first_argument_type& __x) const
       { return op(__x, value); }
-    } _GLIBCXX_DEPRECATED;
+    } _GLIBCXX11_DEPRECATED_SUGGEST("std::bind");
 
   /// One of the @link binders binder functors@endlink.
   template<typename _Operation, typename _Tp>
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index b1fad59d4b3..116faf64441 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -83,22 +83,37 @@
 # define _GLIBCXX_USE_DEPRECATED 1
 #endif
 
-#if defined(__DEPRECATED) && (__cplusplus >= 201103L)
+#if defined(__DEPRECATED)
 # define _GLIBCXX_DEPRECATED __attribute__ ((__deprecated__))
+# define _GLIBCXX_DEPRECATED_SUGGEST(ALT) \
+  __attribute__ ((__deprecated__ ("use '" ALT "' instead")))
 #else
 # define _GLIBCXX_DEPRECATED
+# define _GLIBCXX_DEPRECATED_SUGGEST(ALT)
+#endif
+
+#if defined(__DEPRECATED) && (__cplusplus >= 201103L)
+# define _GLIBCXX11_DEPRECATED _GLIBCXX_DEPRECATED
+# define _GLIBCXX11_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT)
+#else
+# define _GLIBCXX11_DEPRECATED
+# define _GLIBCXX11_DEPRECATED_SUGGEST(ALT)
 #endif
 
 #if defined(__DEPRECATED) && (__cplusplus >= 201703L)
 # define _GLIBCXX17_DEPRECATED [[__deprecated__]]
+# define _GLIBCXX17_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT)
 #else
 # define _GLIBCXX17_DEPRECATED
+# define _GLIBCXX17_DEPRECATED_SUGGEST(ALT)
 #endif
 
 #if defined(__DEPRECATED) && (__cplusplus > 201703L)
 # define _GLIBCXX20_DEPRECATED(MSG) [[deprecated(MSG)]]
+# define _GLIBCXX20_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT)
 #else
 # define _GLIBCXX20_DEPRECATED(MSG)
+# define _GLIBCXX20_DEPRECATED_SUGGEST(ALT)
 #endif
 
 // Macros for ABI tag attributes.
diff --git a/libstdc++-v3/include/bits/ios_base.h b/libstdc++-v3/include/bits/ios_base.h
index d6562544f4d..4ac026547b4 100644
--- a/libstdc++-v3/include/bits/ios_base.h
+++ b/libstdc++-v3/include/bits/ios_base.h
@@ -471,12 +471,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 #if __cplusplus <= 201402L
     // Annex D.6 (removed in C++17)
-    typedef int io_state;
-    typedef int open_mode;
-    typedef int seek_dir;
+    typedef int io_state
+      _GLIBCXX_DEPRECATED_SUGGEST("std::iostate");
+    typedef int open_mode
+      _GLIBCXX_DEPRECATED_SUGGEST("std::openmode");
+    typedef int seek_dir
+      _GLIBCXX_DEPRECATED_SUGGEST("std::seekdir");
 
-    typedef std::streampos streampos;
-    typedef std::streamoff streamoff;
+    typedef std::streampos streampos
+      _GLIBCXX_DEPRECATED_SUGGEST("std::streampos");
+    typedef std::streamoff streamoff
+      _GLIBCXX_DEPRECATED_SUGGEST("std::streamoff");
 #endif
 
     // Callbacks;
diff --git a/libstdc++-v3/include/std/streambuf b/libstdc++-v3/include/std/streambuf
index 3e512364b86..cae35e75bda 100644
--- a/libstdc++-v3/include/std/streambuf
+++ b/libstdc++-v3/include/std/streambuf
@@ -784,9 +784,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        *
        *  See http://gcc.gnu.org/ml/libstdc++/2002-05/msg00168.html
        */
-#if __cplusplus >= 201103L
-      [[__deprecated__("stossc is deprecated, use sbumpc instead")]]
-#endif
+      _GLIBCXX_DEPRECATED_SUGGEST("std::basic_streambuf::sbumpc")
       void
       stossc()
       {
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 62f11902790..6ced781bd59 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -518,7 +518,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Tp>
     struct __is_nullptr_t
     : public is_null_pointer<_Tp>
-    { } _GLIBCXX_DEPRECATED;
+    { } _GLIBCXX_DEPRECATED_SUGGEST("std::is_null_pointer");
 
   // Composite type categories.
 
diff --git a/libstdc++-v3/testsuite/27_io/types/1.cc b/libstdc++-v3/testsuite/27_io/types/1.cc
index 40255ec51d1..a565c205b35 100644
--- a/libstdc++-v3/testsuite/27_io/types/1.cc
+++ b/libstdc++-v3/testsuite/27_io/types/1.cc
@@ -15,6 +15,7 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// { dg-options "-Wdeprecated" }
 // { dg-do compile { target c++14_down } }
 
 // 27.4.2.1 - Types [lib.ios.types]
@@ -26,6 +27,14 @@
 // Annex D, deprecated.
 void test01()
 {
-  typedef std::ios_base::streampos streampos_type;
-  typedef std::ios_base::streamoff streamoff_type;
+  typedef std::ios_base::streampos streampos_type; // { dg-warning "is deprecated: use 'std::streampos' instead" }
+  typedef std::ios_base::streamoff streamoff_type; // { dg-warning "is deprecated: use 'std::streamoff' instead" }
+}
+
+// Annex D, deprecated.
+void test02()
+{
+  typedef std::ios_base::io_state iostate_type; // { dg-warning "is deprecated: use 'std::iostate' instead" }
+  typedef std::ios_base::open_mode openmode_type; // { dg-warning "is deprecated: use 'std::openmode' instead" }
+  typedef std::ios_base::seek_dir seekdir_type; // { dg-warning "is deprecated: use 'std::seekdir' instead" }
 }

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

* Re: [committed] libstdc++: Add deprecated attributes to old iostream members
  2020-08-19 11:29 [committed] libstdc++: Add deprecated attributes to old iostream members Jonathan Wakely
@ 2020-08-19 12:47 ` Jonathan Wakely
  2020-08-19 13:53 ` Jonathan Wakely
  1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Wakely @ 2020-08-19 12:47 UTC (permalink / raw)
  To: libstdc++, gcc-patches

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

On 19/08/20 12:29 +0100, Jonathan Wakely wrote:
>Back in 2017 I removed these prehistoric members (which were deprecated
>since C++98) for C++17 mode. But I didn't add deprecated attributes to
>most of them, so users didn't get any warning they would be going away.
>Apparently some poor souls do actually use some of these names, and so
>now that GCC 11 defaults to -std=gnu++17 some code has stopped
>compiling.
>
>This adds deprecated attributes to them, so that C++98/03/11/14 code
>will get a warning if it uses them. I'll also backport this to the
>release branches so that users can find out about the deprecation before
>they start using C++17.
>
>In order to give deprecated warnings even in C++98 mode this patch makes
>_GLIBCXX_DEPRECATED work even for C++98, adds _GLIBCXX11_DEPRECATED for
>the old meaning of _GLIBCXX_DEPRECATED, and adds new macros such as
>_GLIBCXX_DEPRECATED_SUGGEST for suggesting alternatives to deprecated
>features.
>
>libstdc++-v3/ChangeLog:
>
>	* include/bits/c++config (_GLIBCXX_DEPRECATED): Define for all
>	standard modes.
>	(_GLIBCXX_DEPRECATED_SUGGEST): New macro for "use 'foo' instead"
>	message in deprecated warnings.
>	(_GLIBCXX11_DEPRECATED, _GLIBCXX11_DEPRECATED_SUGGEST): New
>	macros for marking features derpecated in C++11.

I'll try to remember to fix the "derpecated" typo in the ChangeLog
tomorrow.

>	(_GLIBCXX17_DEPRECATED_SUGGEST, _GLIBCXX20_DEPRECATED_SUGGEST):
>	New macros.
>	* include/backward/auto_ptr.h (auto_ptr_ref, auto_ptr<void>):
>	Use _GLIBCXX11_DEPRECATED instead of _GLIBCXX_DEPRECATED.
>	(auto_ptr): Use _GLIBCXX11_DEPRECATED_SUGGEST.
>	* include/backward/binders.h (binder1st, binder2nd): Likewise.
>	* include/bits/ios_base.h (io_state, open_mode, seek_dir)
>	(streampos, streamoff): Use _GLIBCXX_DEPRECATED_SUGGEST.
>	* include/std/streambuf (stossc): Replace C++11 attribute
>	with _GLIBCXX_DEPRECATED_SUGGEST.
>	* include/std/type_traits (__is_nullptr_t): Use
>	_GLIBCXX_DEPRECATED_SUGGEST instead of _GLIBCXX_DEPRECATED.
>	* testsuite/27_io/types/1.cc: Check for deprecated warnings.
>	Also check for io_state, open_mode and seek_dir typedefs.
>
>Tested powerpc64le-linux. Committed to trunk.

The attached patch is the backport I've pushed to the gcc-10 branch,
which only adds the new _GLIBCXX_DEPRECATED_SUGGEST macro and doesn't
enable it for C++98.

The version for gcc-9 is the same but doesn't touch the __is_nullptr_t
trait, because GCC 10.1.0 was the first release to deprecate that.



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

commit 817ac30a8581f75cc25c4c71ef8623eb52953390
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Aug 19 13:41:26 2020

    libstdc++: Add deprecated attributes to old iostream members
    
    Back in 2017 I removed these prehistoric members (which were deprecated
    since C++98) for C++17 mode. But I didn't add deprecated attributes to
    most of them, so users didn't get any warning they would be going away.
    Apparently some poor souls do actually use some of these names, and so
    now that GCC 11 defaults to -std=gnu++17 some code has stopped
    compiling.
    
    This adds deprecated attributes to them, so that C++98/03/11/14 code
    will get a warning if it uses them. I'll also backport this to the
    release branches so that users can find out about the deprecation before
    they start using C++17.
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/c++config (_GLIBCXX_DEPRECATED_SUGGEST): New
            macro for "use 'foo' instead" message in deprecated warnings.
            * include/bits/ios_base.h (io_state, open_mode, seek_dir)
            (streampos, streamoff): Use _GLIBCXX_DEPRECATED_SUGGEST.
            * include/std/streambuf (stossc): Replace C++11 attribute
            with _GLIBCXX_DEPRECATED_SUGGEST.
            * include/std/type_traits (__is_nullptr_t): Use
            _GLIBCXX_DEPRECATED_SUGGEST instead of _GLIBCXX_DEPRECATED.
            * testsuite/27_io/types/1.cc: Check for deprecated warnings.
            Also check for io_state, open_mode and seek_dir typedefs.
    
    (cherry picked from commit eef9bf4ca8d90a1751bc4bff03722ee68999eb8e)

diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index b1fad59d4b3..aa94a681fff 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -77,6 +77,7 @@
 // Macros for deprecated attributes.
 //   _GLIBCXX_USE_DEPRECATED
 //   _GLIBCXX_DEPRECATED
+//   _GLIBCXX_DEPRECATED_SUGGEST
 //   _GLIBCXX17_DEPRECATED
 //   _GLIBCXX20_DEPRECATED( string-literal )
 #ifndef _GLIBCXX_USE_DEPRECATED
@@ -85,8 +86,11 @@
 
 #if defined(__DEPRECATED) && (__cplusplus >= 201103L)
 # define _GLIBCXX_DEPRECATED __attribute__ ((__deprecated__))
+# define _GLIBCXX_DEPRECATED_SUGGEST(ALT) \
+  __attribute__ ((__deprecated__ ("use '" ALT "' instead")))
 #else
 # define _GLIBCXX_DEPRECATED
+# define _GLIBCXX_DEPRECATED_SUGGEST(ALT)
 #endif
 
 #if defined(__DEPRECATED) && (__cplusplus >= 201703L)
diff --git a/libstdc++-v3/include/bits/ios_base.h b/libstdc++-v3/include/bits/ios_base.h
index d6562544f4d..4ac026547b4 100644
--- a/libstdc++-v3/include/bits/ios_base.h
+++ b/libstdc++-v3/include/bits/ios_base.h
@@ -471,12 +471,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 #if __cplusplus <= 201402L
     // Annex D.6 (removed in C++17)
-    typedef int io_state;
-    typedef int open_mode;
-    typedef int seek_dir;
+    typedef int io_state
+      _GLIBCXX_DEPRECATED_SUGGEST("std::iostate");
+    typedef int open_mode
+      _GLIBCXX_DEPRECATED_SUGGEST("std::openmode");
+    typedef int seek_dir
+      _GLIBCXX_DEPRECATED_SUGGEST("std::seekdir");
 
-    typedef std::streampos streampos;
-    typedef std::streamoff streamoff;
+    typedef std::streampos streampos
+      _GLIBCXX_DEPRECATED_SUGGEST("std::streampos");
+    typedef std::streamoff streamoff
+      _GLIBCXX_DEPRECATED_SUGGEST("std::streamoff");
 #endif
 
     // Callbacks;
diff --git a/libstdc++-v3/include/std/streambuf b/libstdc++-v3/include/std/streambuf
index f8e4cb9879c..7cb4fabbb89 100644
--- a/libstdc++-v3/include/std/streambuf
+++ b/libstdc++-v3/include/std/streambuf
@@ -786,9 +786,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        *
        *  See http://gcc.gnu.org/ml/libstdc++/2002-05/msg00168.html
        */
-#if __cplusplus >= 201103L
-      [[__deprecated__("stossc is deprecated, use sbumpc instead")]]
-#endif
+      _GLIBCXX_DEPRECATED_SUGGEST("std::basic_streambuf::sbumpc")
       void
       stossc()
       {
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index bc9a45b3746..c62dc72d3d7 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -518,7 +518,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Tp>
     struct __is_nullptr_t
     : public is_null_pointer<_Tp>
-    { } _GLIBCXX_DEPRECATED;
+    { } _GLIBCXX_DEPRECATED_SUGGEST("std::is_null_pointer");
 
   // Composite type categories.
 
diff --git a/libstdc++-v3/testsuite/27_io/types/1.cc b/libstdc++-v3/testsuite/27_io/types/1.cc
index 40255ec51d1..a565c205b35 100644
--- a/libstdc++-v3/testsuite/27_io/types/1.cc
+++ b/libstdc++-v3/testsuite/27_io/types/1.cc
@@ -15,6 +15,7 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// { dg-options "-Wdeprecated" }
 // { dg-do compile { target c++14_down } }
 
 // 27.4.2.1 - Types [lib.ios.types]
@@ -26,6 +27,14 @@
 // Annex D, deprecated.
 void test01()
 {
-  typedef std::ios_base::streampos streampos_type;
-  typedef std::ios_base::streamoff streamoff_type;
+  typedef std::ios_base::streampos streampos_type; // { dg-warning "is deprecated: use 'std::streampos' instead" }
+  typedef std::ios_base::streamoff streamoff_type; // { dg-warning "is deprecated: use 'std::streamoff' instead" }
+}
+
+// Annex D, deprecated.
+void test02()
+{
+  typedef std::ios_base::io_state iostate_type; // { dg-warning "is deprecated: use 'std::iostate' instead" }
+  typedef std::ios_base::open_mode openmode_type; // { dg-warning "is deprecated: use 'std::openmode' instead" }
+  typedef std::ios_base::seek_dir seekdir_type; // { dg-warning "is deprecated: use 'std::seekdir' instead" }
 }

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

* Re: [committed] libstdc++: Add deprecated attributes to old iostream members
  2020-08-19 11:29 [committed] libstdc++: Add deprecated attributes to old iostream members Jonathan Wakely
  2020-08-19 12:47 ` Jonathan Wakely
@ 2020-08-19 13:53 ` Jonathan Wakely
  1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Wakely @ 2020-08-19 13:53 UTC (permalink / raw)
  To: libstdc++, gcc-patches

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

On 19/08/20 12:29 +0100, Jonathan Wakely wrote:
>Back in 2017 I removed these prehistoric members (which were deprecated
>since C++98) for C++17 mode. But I didn't add deprecated attributes to
>most of them, so users didn't get any warning they would be going away.
>Apparently some poor souls do actually use some of these names, and so
>now that GCC 11 defaults to -std=gnu++17 some code has stopped
>compiling.
>
>This adds deprecated attributes to them, so that C++98/03/11/14 code
>will get a warning if it uses them. I'll also backport this to the
>release branches so that users can find out about the deprecation before
>they start using C++17.
>
>In order to give deprecated warnings even in C++98 mode this patch makes
>_GLIBCXX_DEPRECATED work even for C++98, adds _GLIBCXX11_DEPRECATED for
>the old meaning of _GLIBCXX_DEPRECATED, and adds new macros such as
>_GLIBCXX_DEPRECATED_SUGGEST for suggesting alternatives to deprecated
>features.
>
>libstdc++-v3/ChangeLog:
>
>	* include/bits/c++config (_GLIBCXX_DEPRECATED): Define for all
>	standard modes.
>	(_GLIBCXX_DEPRECATED_SUGGEST): New macro for "use 'foo' instead"
>	message in deprecated warnings.
>	(_GLIBCXX11_DEPRECATED, _GLIBCXX11_DEPRECATED_SUGGEST): New
>	macros for marking features derpecated in C++11.
>	(_GLIBCXX17_DEPRECATED_SUGGEST, _GLIBCXX20_DEPRECATED_SUGGEST):
>	New macros.
>	* include/backward/auto_ptr.h (auto_ptr_ref, auto_ptr<void>):
>	Use _GLIBCXX11_DEPRECATED instead of _GLIBCXX_DEPRECATED.
>	(auto_ptr): Use _GLIBCXX11_DEPRECATED_SUGGEST.
>	* include/backward/binders.h (binder1st, binder2nd): Likewise.
>	* include/bits/ios_base.h (io_state, open_mode, seek_dir)
>	(streampos, streamoff): Use _GLIBCXX_DEPRECATED_SUGGEST.
>	* include/std/streambuf (stossc): Replace C++11 attribute
>	with _GLIBCXX_DEPRECATED_SUGGEST.
>	* include/std/type_traits (__is_nullptr_t): Use
>	_GLIBCXX_DEPRECATED_SUGGEST instead of _GLIBCXX_DEPRECATED.
>	* testsuite/27_io/types/1.cc: Check for deprecated warnings.
>	Also check for io_state, open_mode and seek_dir typedefs.

And this adds the new macros to the comment before their definitions.

Tested powerpc64le-linux. Committed to trunk.


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

commit 1e235788bbfc41f3eec1bb665d8e4bb2c63a1982
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Aug 19 12:42:02 2020

    libstdc++: Mention new macros in comments
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/c++config (_GLIBCXX_DEPRECATED_SUGGEST)
            (_GLIBCXX11_DEPRECATED, _GLIBCXX11_DEPRECATED_SUGGEST)
            (_GLIBCXX17_DEPRECATED_SUGGEST, _GLIBCXX20_DEPRECATED_SUGGEST):
            Add new macros to comment.

diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index 116faf64441..de28acea6b7 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -77,8 +77,13 @@
 // Macros for deprecated attributes.
 //   _GLIBCXX_USE_DEPRECATED
 //   _GLIBCXX_DEPRECATED
+//   _GLIBCXX_DEPRECATED_SUGGEST( string-literal )
+//   _GLIBCXX11_DEPRECATED
+//   _GLIBCXX11_DEPRECATED_SUGGEST( string-literal )
 //   _GLIBCXX17_DEPRECATED
+//   _GLIBCXX17_DEPRECATED_SUGGEST( string-literal )
 //   _GLIBCXX20_DEPRECATED( string-literal )
+//   _GLIBCXX20_DEPRECATED_SUGGEST( string-literal )
 #ifndef _GLIBCXX_USE_DEPRECATED
 # define _GLIBCXX_USE_DEPRECATED 1
 #endif

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

end of thread, other threads:[~2020-08-19 13:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-19 11:29 [committed] libstdc++: Add deprecated attributes to old iostream members Jonathan Wakely
2020-08-19 12:47 ` Jonathan Wakely
2020-08-19 13:53 ` 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).