]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix tests that fail in C++98 mode
authorJonathan Wakely <jwakely@redhat.com>
Tue, 11 May 2021 16:14:26 +0000 (17:14 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 26 Nov 2021 12:51:32 +0000 (12:51 +0000)
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)

libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc
libstdc++-v3/testsuite/20_util/shared_ptr/creation/99006.cc
libstdc++-v3/testsuite/25_algorithms/copy/debug/99402.cc

index 187de621257470f687621c595cac6f35ac5fdd9f..dd4324a39158c2c695e22afc5dd84f1b7e737429 100644 (file)
 
 #include <memory>
 
+#if __cplusplus >= 201103L
+# define NOTHROW noexcept
+#else
+# define NOTHROW
+#endif
+
 namespace std {
   //  lib.default.allocator, the default allocator:
   template <class T> class allocator;
@@ -40,7 +46,7 @@ namespace std {
 
   //  lib.temporary.buffer, temporary buffers:
   template <class T>
-  pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n);
+  pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n) NOTHROW;
   template <class T>
   void return_temporary_buffer(T* p);
 
index d5f7a5da5e9d2a3238ff8e27b4ad38e62ad42c87..e070fb9d42057566be9071868805313da00cda18 100644 (file)
@@ -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 <memory>
 
index 041d222d07900883d563a77606d981e3eeb3167f..9a9c97af6052d8dab4ea6b9680a8c136e90f3494 100644 (file)
@@ -28,8 +28,9 @@ using namespace std;
 
 int main()
 {
+    int two[] = { 0, 1 };
     // any container with non-random access iterators:
-    const set<int> source = { 0, 1 };
+    const set<int> source(two, two + 2);
     vector<int> dest(1);
     copy(source.begin(), ++source.begin(), dest.begin());
 }