diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2022-05-05 09:50:53 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2022-05-05 21:13:58 +0100 |
commit | b6b66006787b0991e94f15c7b5c56403f1eb85fb (patch) | |
tree | 18845b0f848d1cb6edcb7e866efb6e18a36ca2eb /libstdc++-v3/testsuite/20_util/any | |
parent | b06a79b82366a53fffc113f3bb5f873dbc70e381 (diff) | |
download | gcc-b6b66006787b0991e94f15c7b5c56403f1eb85fb.tar.gz |
libstdc++: Fixes for tests that fail with -fno-rtti
This disables a use of dynamic_cast that is not valid for -fno-rtti and
adjusts some tests so they don't FAIL with -fno-rtti. Some tests are
skipped completely, and others just make use of typeid conditional on
the __cpp_rtti macro. A couple of tests were using typeid to verify
typedefs denote the right type, which can be done at compile-time using
templates instead.
libstdc++-v3/ChangeLog:
* include/experimental/memory_resource [!__cpp_rtti]
(__resource_adaptor_imp::do_is_equal): Do not use dynamic_cast
when RTTI is disabled.
* testsuite/17_intro/freestanding.cc: Require RTTI.
* testsuite/18_support/exception/38732.cc: Likewise.
* testsuite/18_support/exception_ptr/rethrow_exception.cc:
Likewise.
* testsuite/18_support/nested_exception/68139.cc: Likewise.
* testsuite/18_support/nested_exception/rethrow_if_nested.cc:
Likewise.
* testsuite/18_support/type_info/103240.cc: Likewise.
* testsuite/18_support/type_info/fundamental.cc: Likewise.
* testsuite/18_support/type_info/hash_code.cc: Likewise.
* testsuite/20_util/any/assign/emplace.cc: Likewise.
* testsuite/20_util/any/cons/in_place.cc: Likewise.
* testsuite/20_util/any/misc/any_cast.cc: Likewise.
* testsuite/20_util/any/observers/type.cc: Likewise.
* testsuite/20_util/function/1.cc: Likewise.
* testsuite/20_util/function/2.cc: Likewise.
* testsuite/20_util/function/3.cc: Likewise.
* testsuite/20_util/function/4.cc: Likewise.
* testsuite/20_util/function/5.cc: Likewise.
* testsuite/20_util/function/6.cc: Likewise.
* testsuite/20_util/function/7.cc: Likewise.
* testsuite/20_util/function/8.cc: Likewise.
* testsuite/20_util/polymorphic_allocator/resource.cc: Likewise.
* testsuite/20_util/shared_ptr/casts/1.cc: Likewise.
* testsuite/20_util/shared_ptr/casts/rval.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_2.cc:
Likewise.
* testsuite/20_util/shared_ptr/misc/get_deleter.cc: Likewise.
* testsuite/20_util/typeindex/comparison_operators.cc: Likewise.
* testsuite/20_util/typeindex/comparison_operators_c++20.cc:
Likewise.
* testsuite/20_util/typeindex/hash.cc: Likewise.
* testsuite/20_util/typeindex/hash_code.cc: Likewise.
* testsuite/20_util/typeindex/name.cc: Likewise.
* testsuite/22_locale/ctype/is/string/89728_neg.cc: Likewise.
* testsuite/22_locale/global_templates/standard_facet_hierarchies.cc:
Likewise.
* testsuite/22_locale/global_templates/user_facet_hierarchies.cc:
Likewise.
* testsuite/22_locale/locale/13630.cc: Check type without using
RTTI.
* testsuite/23_containers/array/requirements/non_default_constructible.cc:
Require RTTI.
* testsuite/27_io/basic_ostream/emit/1.cc: Likewise.
* testsuite/27_io/fpos/14320-1.cc: Check type without using RTTI.
* testsuite/27_io/fpos/mbstate_t/12065.cc: Require RTTI.
* testsuite/27_io/ios_base/failure/dual_abi.cc: Likewise.
* testsuite/experimental/any/misc/any_cast.cc: Likewise.
* testsuite/experimental/any/observers/type.cc: Likewise.
* testsuite/experimental/memory_resource/resource_adaptor.cc:
Likewise.
* testsuite/lib/libstdc++.exp (check_effective_target_rtti):
Define new proc.
* testsuite/tr1/3_function_objects/function/1.cc: Likewise.
* testsuite/tr1/3_function_objects/function/2.cc: Likewise.
* testsuite/tr1/3_function_objects/function/3.cc: Likewise.
* testsuite/tr1/3_function_objects/function/4.cc: Likewise.
* testsuite/tr1/3_function_objects/function/5.cc: Likewise.
* testsuite/tr1/3_function_objects/function/6.cc: Likewise.
* testsuite/tr1/3_function_objects/function/7.cc: Likewise.
* testsuite/tr1/3_function_objects/function/8.cc: Likewise.
* testsuite/tr2/bases/value.cc: Likewise.
* testsuite/tr2/direct_bases/value.cc: Likewise.
* testsuite/util/exception/safety.h [!__cpp_rtti]: Don't print
types without RTTI.
Diffstat (limited to 'libstdc++-v3/testsuite/20_util/any')
4 files changed, 11 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/20_util/any/assign/emplace.cc b/libstdc++-v3/testsuite/20_util/any/assign/emplace.cc index 168377f0493..74885f923e4 100644 --- a/libstdc++-v3/testsuite/20_util/any/assign/emplace.cc +++ b/libstdc++-v3/testsuite/20_util/any/assign/emplace.cc @@ -58,6 +58,7 @@ int main() combined& c2 = std::any_cast<combined&>(o5); VERIFY(c2.v[0] == 1 && c2.v[1] == 2 && std::get<0>(c2.t) == 3 && std::get<1>(c2.t) == 4 ); +#if __cpp_rtti std::any o6; o6.emplace<const int&>(i); VERIFY(o6.type() == o.type()); @@ -71,6 +72,7 @@ int main() std::any o10; o10.emplace<char*>(nullptr); VERIFY(o9.type() == o10.type()); +#endif std::any o11; VERIFY(&o11.emplace<int>(42) == &std::any_cast<int&>(o11)); VERIFY(&o11.emplace<std::vector<int>>({1,2,3}) == diff --git a/libstdc++-v3/testsuite/20_util/any/cons/in_place.cc b/libstdc++-v3/testsuite/20_util/any/cons/in_place.cc index fbcd58df879..fabffe5a890 100644 --- a/libstdc++-v3/testsuite/20_util/any/cons/in_place.cc +++ b/libstdc++-v3/testsuite/20_util/any/cons/in_place.cc @@ -53,6 +53,7 @@ int main() combined& c2 = std::any_cast<combined&>(o5); VERIFY(c2.v[0] == 1 && c2.v[1] == 2 && std::get<0>(c2.t) == 3 && std::get<1>(c2.t) == 4 ); +#if __cpp_rtti std::any o6(std::in_place_type<int&>, i); VERIFY(o6.type() == o.type()); std::any o7(std::in_place_type<void()>, nullptr); @@ -61,4 +62,5 @@ int main() std::any o9(std::in_place_type<char(&)[42]>, nullptr); std::any o10(std::in_place_type<char*>, nullptr); VERIFY(o9.type() == o10.type()); +#endif } diff --git a/libstdc++-v3/testsuite/20_util/any/misc/any_cast.cc b/libstdc++-v3/testsuite/20_util/any/misc/any_cast.cc index 9241b0c121c..8d63dfbba9b 100644 --- a/libstdc++-v3/testsuite/20_util/any/misc/any_cast.cc +++ b/libstdc++-v3/testsuite/20_util/any/misc/any_cast.cc @@ -157,13 +157,19 @@ void test07() { int arr[3]; any a(arr); +#if __cpp_rtti VERIFY( a.type() == typeid(int*) ); // contained value is decayed +#endif int (*p1)[3] = any_cast<int[3]>(&a); +#if __cpp_rtti VERIFY( a.type() != typeid(int[3]) ); // so any_cast should return nullptr +#endif VERIFY( p1 == nullptr ); int (*p2)[] = any_cast<int[]>(&a); +#if __cpp_rtti VERIFY( a.type() != typeid(int[]) ); // so any_cast should return nullptr +#endif VERIFY( p2 == nullptr ); const int (*p3)[] = any_cast<int[]>(&std::as_const(a)); VERIFY( p3 == nullptr ); diff --git a/libstdc++-v3/testsuite/20_util/any/observers/type.cc b/libstdc++-v3/testsuite/20_util/any/observers/type.cc index f8f52704961..4d2f302d31e 100644 --- a/libstdc++-v3/testsuite/20_util/any/observers/type.cc +++ b/libstdc++-v3/testsuite/20_util/any/observers/type.cc @@ -1,4 +1,5 @@ // { dg-do run { target c++17 } } +// { dg-require-effective-target rtti } // Copyright (C) 2014-2022 Free Software Foundation, Inc. // |