From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 7AF54385843D; Fri, 26 Nov 2021 12:52:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7AF54385843D MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r10-10299] libstdc++: Fix tests that fail in C++98 mode X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/releases/gcc-10 X-Git-Oldrev: 5b4d29b50d5d15c6bbc17cf9a74f668f6dd79b90 X-Git-Newrev: 5cc7018538ad2ad8e9379271ae721f20fbc22d1c Message-Id: <20211126125257.7AF54385843D@sourceware.org> Date: Fri, 26 Nov 2021 12:52:57 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Nov 2021 12:52:57 -0000 https://gcc.gnu.org/g:5cc7018538ad2ad8e9379271ae721f20fbc22d1c commit r10-10299-g5cc7018538ad2ad8e9379271ae721f20fbc22d1c Author: Jonathan Wakely Date: Tue May 11 17:14:26 2021 +0100 libstdc++: Fix tests that fail in C++98 mode The header synopsis test fails to define NOTHROW for C++98. The shared_ptr test should be skipped for C++98. The debug mode one should work for C++98 too, it just needs to avoid C++11 syntax that isn't valid in C++98. libstdc++-v3/ChangeLog: * testsuite/20_util/headers/memory/synopsis.cc: Define C++98 alternative for macro. * testsuite/20_util/shared_ptr/creation/99006.cc: Add effective target keyword. * testsuite/25_algorithms/copy/debug/99402.cc: Avoid C++11 syntax. (cherry picked from commit 37407a2ae701c0a93377106a2938ab5474062fc3) Diff: --- libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc | 8 +++++++- libstdc++-v3/testsuite/20_util/shared_ptr/creation/99006.cc | 4 ++-- libstdc++-v3/testsuite/25_algorithms/copy/debug/99402.cc | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc b/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc index 187de621257..dd4324a3915 100644 --- a/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc +++ b/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc @@ -20,6 +20,12 @@ #include +#if __cplusplus >= 201103L +# define NOTHROW noexcept +#else +# define NOTHROW +#endif + namespace std { // lib.default.allocator, the default allocator: template class allocator; @@ -40,7 +46,7 @@ namespace std { // lib.temporary.buffer, temporary buffers: template - pair get_temporary_buffer(ptrdiff_t n); + pair get_temporary_buffer(ptrdiff_t n) NOTHROW; template void return_temporary_buffer(T* p); diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/creation/99006.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/creation/99006.cc index d5f7a5da5e9..e070fb9d420 100644 --- a/libstdc++-v3/testsuite/20_util/shared_ptr/creation/99006.cc +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/creation/99006.cc @@ -1,5 +1,5 @@ -// FIXME: This should use { target { ! c++20 } } -// { dg-do compile } +// FIXME: This should use { target { c++11 && { ! c++20 } } } +// { dg-do compile { target { c++11 } } } #include diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/debug/99402.cc b/libstdc++-v3/testsuite/25_algorithms/copy/debug/99402.cc index 041d222d079..9a9c97af605 100644 --- a/libstdc++-v3/testsuite/25_algorithms/copy/debug/99402.cc +++ b/libstdc++-v3/testsuite/25_algorithms/copy/debug/99402.cc @@ -28,8 +28,9 @@ using namespace std; int main() { + int two[] = { 0, 1 }; // any container with non-random access iterators: - const set source = { 0, 1 }; + const set source(two, two + 2); vector dest(1); copy(source.begin(), ++source.begin(), dest.begin()); }