From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 456753857C54; Wed, 19 Aug 2020 12:41:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 456753857C54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1597840893; bh=fSwPg9djvRo4l2srd65KdRnLTMVhzjPt5MDCrq5nTcU=; h=From:To:Subject:Date:From; b=IcLfPKbgxT7SC8ZI5rkiEHZy9rUvhKYzOSlleZYZbiwhMRdrFPz/AapYOE9k09yIT OlyZts2/dHZEfRF01gZjPyKkhxpopiOz94Eh13TYCvwDLfPdI4UyHq5PPET5sLDdWR po+fqvCpaz9MTRSae8mCmI9xMimg+vh1+GA2nLT0= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r10-8644] libstdc++: Add deprecated attributes to old iostream members X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/releases/gcc-10 X-Git-Oldrev: 10e0d2010f0597e6ae7efb88142b8820608c585e X-Git-Newrev: 817ac30a8581f75cc25c4c71ef8623eb52953390 Message-Id: <20200819124133.456753857C54@sourceware.org> Date: Wed, 19 Aug 2020 12:41:33 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Aug 2020 12:41:33 -0000 https://gcc.gnu.org/g:817ac30a8581f75cc25c4c71ef8623eb52953390 commit r10-8644-g817ac30a8581f75cc25c4c71ef8623eb52953390 Author: Jonathan Wakely Date: Wed Aug 19 13:41:26 2020 +0100 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: --- libstdc++-v3/include/bits/c++config | 4 ++++ libstdc++-v3/include/bits/ios_base.h | 17 +++++++++++------ libstdc++-v3/include/std/streambuf | 4 +--- libstdc++-v3/include/std/type_traits | 2 +- libstdc++-v3/testsuite/27_io/types/1.cc | 13 +++++++++++-- 5 files changed, 28 insertions(+), 12 deletions(-) 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 std::streampos streampos; - typedef std::streamoff streamoff; + 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 + _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 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 // . +// { 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" } }