From 450eb6b3b5b544d26da2535228ce03f9656a13a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arsen=20Arsenovi=C4=87?= Date: Tue, 10 Jan 2023 11:03:05 +0100 Subject: 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. --- libstdc++-v3/testsuite/20_util/to_chars/version.cc | 1 + .../testsuite/20_util/uses_allocator/lwg3677.cc | 1 + .../testsuite/20_util/weak_ptr/cons/self_move.cc | 1 + .../basic_string_view/operations/contains/char.cc | 13 ++++++++----- .../basic_string_view/operations/contains/char/2.cc | 11 +++++++---- .../testsuite/std/ranges/adaptors/as_rvalue/1.cc | 19 +++++++++++++++---- libstdc++-v3/testsuite/std/ranges/version_c++23.cc | 6 ++++-- 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 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 #include 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 #include 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 -#ifndef __cpp_lib_string_contains -# error "Feature-test macro for contains missing in " -#elif __cpp_lib_string_contains != 202011L -# error "Feature-test macro for contains has wrong value in " -#endif +#if __STDC_HOSTED__ +// This FTM is omitted since is not freestanding. +# ifndef __cpp_lib_string_contains +# error "Feature-test macro for contains missing in " +# elif __cpp_lib_string_contains != 202011L +# error "Feature-test macro for contains has wrong value in " +# 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 -#ifndef __cpp_lib_string_contains -# error "Feature-test macro for contains missing in " -#elif __cpp_lib_string_contains != 202011L -# error "Feature-test macro for contains has wrong value in " +#if __STDC_HOSTED__ +// This FTM is omitted since is not freestanding. +# ifndef __cpp_lib_string_contains +# error "Feature-test macro for contains missing in " +# elif __cpp_lib_string_contains != 202011L +# error "Feature-test macro for contains has wrong value in " +# 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 +requires (!std::is_array_v) +constexpr auto +make_unique (Args &&...args) +{ + return std::unique_ptr { new T (std::forward(args)...) }; +} + constexpr bool test01() { - std::unique_ptr a[3] = { std::make_unique(1), - std::make_unique(2), - std::make_unique(3) }; + std::unique_ptr a[3] = { make_unique(1), + make_unique(2), + make_unique(3) }; std::unique_ptr b[3]; auto v = a | views::as_rvalue; ranges::copy(v, b); @@ -33,7 +44,7 @@ test01() void test02() { - std::unique_ptr x = std::make_unique(42); + std::unique_ptr x = make_unique(42); std::unique_ptr 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 -#if __cpp_lib_ranges != 202110L -# error "Feature-test macro __cpp_lib_ranges has wrong value in " +#if __STDC_HOSTED__ +# if __cpp_lib_ranges != 202110L +# error "Feature-test macro __cpp_lib_ranges has wrong value in " +# endif #endif #if __cpp_lib_ranges_zip != 202110L -- cgit v1.1