From: Jonathan Wakely Date: Wed, 7 Jun 2023 12:01:36 +0000 (+0100) Subject: libstdc++: Fix some tests that fail with -fno-exceptions X-Git-Tag: basepoints/gcc-15~8527 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa8b4468e0d124bec0fdbfc0a168bd8c377b08ec;p=thirdparty%2Fgcc.git libstdc++: Fix some tests that fail with -fno-exceptions libstdc++-v3/ChangeLog: * testsuite/18_support/nested_exception/rethrow_if_nested-term.cc: Require effective target exceptions_enabled instead of using dg-skip-if. * testsuite/23_containers/vector/capacity/constexpr.cc: Expect shrink_to_fit() to be a no-op without exceptions enabled. * testsuite/23_containers/vector/capacity/shrink_to_fit.cc: Likewise. * testsuite/ext/bitmap_allocator/check_allocate_max_size.cc: Require effective target exceptions_enabled. * testsuite/ext/malloc_allocator/check_allocate_max_size.cc: Likewise. * testsuite/ext/mt_allocator/check_allocate_max_size.cc: Likewise. * testsuite/ext/new_allocator/check_allocate_max_size.cc: Likewise. * testsuite/ext/pool_allocator/check_allocate_max_size.cc: Likewise. * testsuite/ext/throw_allocator/check_allocate_max_size.cc: Likewise. --- diff --git a/libstdc++-v3/testsuite/18_support/nested_exception/rethrow_if_nested-term.cc b/libstdc++-v3/testsuite/18_support/nested_exception/rethrow_if_nested-term.cc index 5913392bd461..3bfc7ab99436 100644 --- a/libstdc++-v3/testsuite/18_support/nested_exception/rethrow_if_nested-term.cc +++ b/libstdc++-v3/testsuite/18_support/nested_exception/rethrow_if_nested-term.cc @@ -1,5 +1,5 @@ // { dg-do run { target c++11 } } -// { dg-skip-if "" { *-*-* } { "-fno-exceptions" } } +// { dg-require-effective-target exceptions_enabled } #include #include diff --git a/libstdc++-v3/testsuite/23_containers/vector/capacity/constexpr.cc b/libstdc++-v3/testsuite/23_containers/vector/capacity/constexpr.cc index 92c23035e4f3..f102e78425b9 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/capacity/constexpr.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/capacity/constexpr.cc @@ -89,11 +89,19 @@ test_shrink_to_fit() std::vector v; v.reserve(9); v.shrink_to_fit(); +#if __cpp_exceptions VERIFY( v.capacity() == 0 ); +#else + VERIFY( v.capacity() == 9 ); +#endif v.reserve(9); v.resize(5); v.shrink_to_fit(); +#if __cpp_exceptions VERIFY( v.capacity() == v.size() ); +#else + VERIFY( v.capacity() == 9 ); +#endif return true; } diff --git a/libstdc++-v3/testsuite/23_containers/vector/capacity/shrink_to_fit.cc b/libstdc++-v3/testsuite/23_containers/vector/capacity/shrink_to_fit.cc index a8cede2278d8..6542b5fd39f6 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/capacity/shrink_to_fit.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/capacity/shrink_to_fit.cc @@ -30,7 +30,11 @@ void test01() v.push_back(1); VERIFY( v.size() < v.capacity() ); v.shrink_to_fit(); +#if __cpp_exceptions VERIFY( v.size() == v.capacity() ); +#else + VERIFY( v.size() < v.capacity() ); +#endif } int main() diff --git a/libstdc++-v3/testsuite/ext/bitmap_allocator/check_allocate_max_size.cc b/libstdc++-v3/testsuite/ext/bitmap_allocator/check_allocate_max_size.cc index 712489f26a92..e523bb8f6c2c 100644 --- a/libstdc++-v3/testsuite/ext/bitmap_allocator/check_allocate_max_size.cc +++ b/libstdc++-v3/testsuite/ext/bitmap_allocator/check_allocate_max_size.cc @@ -16,6 +16,8 @@ // with this library; see the file COPYING3. If not see // . +// { dg-require-effective-target exceptions_enabled } + // 20.4.1.1 allocator members #include diff --git a/libstdc++-v3/testsuite/ext/malloc_allocator/check_allocate_max_size.cc b/libstdc++-v3/testsuite/ext/malloc_allocator/check_allocate_max_size.cc index 53fb8d4ab31d..e59f6ad99b96 100644 --- a/libstdc++-v3/testsuite/ext/malloc_allocator/check_allocate_max_size.cc +++ b/libstdc++-v3/testsuite/ext/malloc_allocator/check_allocate_max_size.cc @@ -16,6 +16,8 @@ // with this library; see the file COPYING3. If not see // . +// { dg-require-effective-target exceptions_enabled } + // 20.4.1.1 allocator members #include diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/check_allocate_max_size.cc b/libstdc++-v3/testsuite/ext/mt_allocator/check_allocate_max_size.cc index cc6f94bb2d0d..b636098b5c9a 100644 --- a/libstdc++-v3/testsuite/ext/mt_allocator/check_allocate_max_size.cc +++ b/libstdc++-v3/testsuite/ext/mt_allocator/check_allocate_max_size.cc @@ -16,6 +16,8 @@ // with this library; see the file COPYING3. If not see // . +// { dg-require-effective-target exceptions_enabled } + // 20.4.1.1 allocator members #include diff --git a/libstdc++-v3/testsuite/ext/new_allocator/check_allocate_max_size.cc b/libstdc++-v3/testsuite/ext/new_allocator/check_allocate_max_size.cc index 80eece038dcd..dbe7307636c5 100644 --- a/libstdc++-v3/testsuite/ext/new_allocator/check_allocate_max_size.cc +++ b/libstdc++-v3/testsuite/ext/new_allocator/check_allocate_max_size.cc @@ -16,6 +16,8 @@ // with this library; see the file COPYING3. If not see // . +// { dg-require-effective-target exceptions_enabled } + // 20.4.1.1 allocator members #include diff --git a/libstdc++-v3/testsuite/ext/pool_allocator/check_allocate_max_size.cc b/libstdc++-v3/testsuite/ext/pool_allocator/check_allocate_max_size.cc index 7ad5f7015216..6eecb74bcdf3 100644 --- a/libstdc++-v3/testsuite/ext/pool_allocator/check_allocate_max_size.cc +++ b/libstdc++-v3/testsuite/ext/pool_allocator/check_allocate_max_size.cc @@ -16,6 +16,8 @@ // with this library; see the file COPYING3. If not see // . +// { dg-require-effective-target exceptions_enabled } + // 20.4.1.1 allocator members #include diff --git a/libstdc++-v3/testsuite/ext/throw_allocator/check_allocate_max_size.cc b/libstdc++-v3/testsuite/ext/throw_allocator/check_allocate_max_size.cc index 424d87b9df6a..73fec6ff0715 100644 --- a/libstdc++-v3/testsuite/ext/throw_allocator/check_allocate_max_size.cc +++ b/libstdc++-v3/testsuite/ext/throw_allocator/check_allocate_max_size.cc @@ -18,6 +18,7 @@ // { dg-require-time "" } // { dg-require-cstdint "" } +// { dg-require-effective-target exceptions_enabled } #include #include