public inbox for libstdc++-cvs@sourceware.org help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r11-7215] libstdc++: Make test memory_resource work without exceptions and RTTI Date: Fri, 12 Feb 2021 14:44:10 +0000 (GMT) [thread overview] Message-ID: <20210212144410.C2BD738708B6@sourceware.org> (raw) https://gcc.gnu.org/g:0bd242ec5aeffd1fb2a3ee16a2c69afae2aff2ce commit r11-7215-g0bd242ec5aeffd1fb2a3ee16a2c69afae2aff2ce Author: Jonathan Wakely <jwakely@redhat.com> Date: Fri Feb 12 11:23:28 2021 +0000 libstdc++: Make test memory_resource work without exceptions and RTTI libstdc++-v3/ChangeLog: * testsuite/util/testsuite_allocator.h (memory_resource): Remove requirement for RTTI and exceptions to be enabled. Diff: --- libstdc++-v3/testsuite/util/testsuite_allocator.h | 26 ++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/libstdc++-v3/testsuite/util/testsuite_allocator.h b/libstdc++-v3/testsuite/util/testsuite_allocator.h index 9f80a14beb0..1f7912ea6eb 100644 --- a/libstdc++-v3/testsuite/util/testsuite_allocator.h +++ b/libstdc++-v3/testsuite/util/testsuite_allocator.h @@ -763,7 +763,7 @@ namespace __gnu_test #endif // C++11 #if __cplusplus >= 201703L -#if __cpp_aligned_new && __cpp_rtti && __cpp_exceptions +#if __cpp_aligned_new // A concrete memory_resource, with error checking. class memory_resource : public std::pmr::memory_resource { @@ -842,9 +842,9 @@ namespace __gnu_test if (p == a->p) { if (bytes != a->bytes) - throw bad_size(); + _S_throw<bad_size>(); if (alignment != a->alignment) - throw bad_alignment(); + _S_throw<bad_alignment>(); #if __cpp_sized_deallocation ::operator delete(p, bytes, std::align_val_t(alignment)); #else @@ -857,19 +857,35 @@ namespace __gnu_test } aptr = &a->next; } - throw bad_address(); + _S_throw<bad_address>(); } bool do_is_equal(const std::pmr::memory_resource& r) const noexcept override { +#if __cpp_rtti // Equality is determined by sharing the same allocation_lists object. if (auto p = dynamic_cast<const memory_resource*>(&r)) return p->lists == lists; +#else + if (this == &r) // Is this the best we can do without RTTI? + return true; +#endif return false; } private: + template<typename E> + static void + _S_throw() + { +#if __cpp_exceptions + throw E(); +#else + __builtin_abort(); +#endif + } + struct allocation { void* p; @@ -905,7 +921,7 @@ namespace __gnu_test allocation_lists* lists; }; -#endif // aligned-new && rtti +#endif // aligned-new // Set the default resource, and restore the previous one on destruction. struct default_resource_mgr
reply other threads:[~2021-02-12 14:44 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210212144410.C2BD738708B6@sourceware.org \ --to=redi@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).