aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArsen Arsenović <arsen@aarsen.me>2023-01-10 11:03:05 +0100
committerJonathan Wakely <jwakely@redhat.com>2023-01-13 13:34:21 +0000
commit450eb6b3b5b544d26da2535228ce03f9656a13a5 (patch)
tree37a9d34055bbbb98e9f590f9e6d4fc91f087e881
parent42d3f74323800d2ce5853dfb9180a5be1ff28d04 (diff)
downloadgcc-450eb6b3b5b544d26da2535228ce03f9656a13a5.zip
gcc-450eb6b3b5b544d26da2535228ce03f9656a13a5.tar.gz
gcc-450eb6b3b5b544d26da2535228ce03f9656a13a5.tar.bz2
libstdc++: Fix a few !HOSTED test regressions
libstdc++-v3/ChangeLog: * testsuite/20_util/to_chars/version.cc: Mark hosted-only. * testsuite/20_util/uses_allocator/lwg3677.cc: Ditto. * testsuite/20_util/weak_ptr/cons/self_move.cc: Ditto. * testsuite/std/ranges/adaptors/as_rvalue/1.cc: Replace usage of std::make_unique with a freestanding-compatible wrapper around unique_ptr. * testsuite/21_strings/basic_string_view/operations/contains/char.cc: Don't test for presence of __cpp_lib_string_contains on !HOSTED. * testsuite/21_strings/basic_string_view/operations/contains/char/2.cc: Ditto. * testsuite/std/ranges/version_c++23.cc: Don't test for presence of __cpp_lib_ranges in !HOSTED.
-rw-r--r--libstdc++-v3/testsuite/20_util/to_chars/version.cc1
-rw-r--r--libstdc++-v3/testsuite/20_util/uses_allocator/lwg3677.cc1
-rw-r--r--libstdc++-v3/testsuite/20_util/weak_ptr/cons/self_move.cc1
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string_view/operations/contains/char.cc13
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string_view/operations/contains/char/2.cc11
-rw-r--r--libstdc++-v3/testsuite/std/ranges/adaptors/as_rvalue/1.cc19
-rw-r--r--libstdc++-v3/testsuite/std/ranges/version_c++23.cc6
7 files changed, 37 insertions, 15 deletions
diff --git a/libstdc++-v3/testsuite/20_util/to_chars/version.cc b/libstdc++-v3/testsuite/20_util/to_chars/version.cc
index 25b1e00..2789afa 100644
--- a/libstdc++-v3/testsuite/20_util/to_chars/version.cc
+++ b/libstdc++-v3/testsuite/20_util/to_chars/version.cc
@@ -1,5 +1,6 @@
// { dg-options "-std=gnu++23" }
// { dg-do preprocess { target c++23 } }
+// { dg-require-effective-target hosted }
#include <version>
diff --git a/libstdc++-v3/testsuite/20_util/uses_allocator/lwg3677.cc b/libstdc++-v3/testsuite/20_util/uses_allocator/lwg3677.cc
index 649b98d..b2595d0 100644
--- a/libstdc++-v3/testsuite/20_util/uses_allocator/lwg3677.cc
+++ b/libstdc++-v3/testsuite/20_util/uses_allocator/lwg3677.cc
@@ -1,5 +1,6 @@
// { dg-options "-std=gnu++23" }
// { dg-do run { target c++20 } }
+// { dg-require-effective-target hosted }
#include <memory>
#include <testsuite_hooks.h>
diff --git a/libstdc++-v3/testsuite/20_util/weak_ptr/cons/self_move.cc b/libstdc++-v3/testsuite/20_util/weak_ptr/cons/self_move.cc
index c890d2b..7e38765 100644
--- a/libstdc++-v3/testsuite/20_util/weak_ptr/cons/self_move.cc
+++ b/libstdc++-v3/testsuite/20_util/weak_ptr/cons/self_move.cc
@@ -1,4 +1,5 @@
// { dg-do run { target c++11 } }
+// { dg-require-effective-target hosted }
#include <memory>
#include <testsuite_hooks.h>
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/contains/char.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/contains/char.cc
index c71a6dc..8ae5675 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/contains/char.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/contains/char.cc
@@ -22,11 +22,14 @@
#include <string_view>
-#ifndef __cpp_lib_string_contains
-# error "Feature-test macro for contains missing in <string_view>"
-#elif __cpp_lib_string_contains != 202011L
-# error "Feature-test macro for contains has wrong value in <string_view>"
-#endif
+#if __STDC_HOSTED__
+// This FTM is omitted since <string> is not freestanding.
+# ifndef __cpp_lib_string_contains
+# error "Feature-test macro for contains missing in <string_view>"
+# elif __cpp_lib_string_contains != 202011L
+# error "Feature-test macro for contains has wrong value in <string_view>"
+# endif
+#endif // HOSTED
void
test01()
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/contains/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/contains/char/2.cc
index c106a55..d8c85e2 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/contains/char/2.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/contains/char/2.cc
@@ -20,8 +20,11 @@
#include <version>
-#ifndef __cpp_lib_string_contains
-# error "Feature-test macro for contains missing in <string_view>"
-#elif __cpp_lib_string_contains != 202011L
-# error "Feature-test macro for contains has wrong value in <string_view>"
+#if __STDC_HOSTED__
+// This FTM is omitted since <string> is not freestanding.
+# ifndef __cpp_lib_string_contains
+# error "Feature-test macro for contains missing in <string_view>"
+# elif __cpp_lib_string_contains != 202011L
+# error "Feature-test macro for contains has wrong value in <string_view>"
+# endif
#endif
diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/as_rvalue/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/as_rvalue/1.cc
index fbf0d65..da82960 100644
--- a/libstdc++-v3/testsuite/std/ranges/adaptors/as_rvalue/1.cc
+++ b/libstdc++-v3/testsuite/std/ranges/adaptors/as_rvalue/1.cc
@@ -14,13 +14,24 @@
namespace ranges = std::ranges;
namespace views = std::views;
+
+/* Replacement for the standard version, as it's not available in freestanding
+ environments. */
+template<typename T, typename... Args>
+requires (!std::is_array_v<T>)
+constexpr auto
+make_unique (Args &&...args)
+{
+ return std::unique_ptr<T> { new T (std::forward<Args>(args)...) };
+}
+
constexpr bool
test01()
{
- std::unique_ptr<int> a[3] = { std::make_unique<int>(1),
- std::make_unique<int>(2),
- std::make_unique<int>(3) };
+ std::unique_ptr<int> a[3] = { make_unique<int>(1),
+ make_unique<int>(2),
+ make_unique<int>(3) };
std::unique_ptr<int> b[3];
auto v = a | views::as_rvalue;
ranges::copy(v, b);
@@ -33,7 +44,7 @@ test01()
void
test02()
{
- std::unique_ptr<int> x = std::make_unique<int>(42);
+ std::unique_ptr<int> x = make_unique<int>(42);
std::unique_ptr<int> y;
__gnu_test::test_input_range rx(&x, &x+1);
auto v = rx | views::as_rvalue;
diff --git a/libstdc++-v3/testsuite/std/ranges/version_c++23.cc b/libstdc++-v3/testsuite/std/ranges/version_c++23.cc
index d9ea9ec..9970301 100644
--- a/libstdc++-v3/testsuite/std/ranges/version_c++23.cc
+++ b/libstdc++-v3/testsuite/std/ranges/version_c++23.cc
@@ -3,8 +3,10 @@
#include <version>
-#if __cpp_lib_ranges != 202110L
-# error "Feature-test macro __cpp_lib_ranges has wrong value in <version>"
+#if __STDC_HOSTED__
+# if __cpp_lib_ranges != 202110L
+# error "Feature-test macro __cpp_lib_ranges has wrong value in <version>"
+# endif
#endif
#if __cpp_lib_ranges_zip != 202110L