From patchwork Fri Feb 12 14:45:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1439869 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=F7tv/UMk; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dcbsg2y6vz9sS8 for ; Sat, 13 Feb 2021 01:46:15 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 74A1D3947422; Fri, 12 Feb 2021 14:46:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 74A1D3947422 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1613141166; bh=BXp5thWx3TdYW1Sbcw3ZeZsdDEcv/Wo2c/CTO07KgqI=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=F7tv/UMk2ONq4YEO33AQFe101YtOCGnBcZYf4Tpy2Lp1e/HQ6oaodFrlveyLM8npk 5gW05PxLH1OuJ1IdSLsits66C/Hga4WpiGfyRcOWBfOKjly3V12fNplxi+UiGi9gYI rpvreixjD/TeWd0n5Cqcyw6G4kqbtMMKUke/dwbg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id D44813945C31 for ; Fri, 12 Feb 2021 14:46:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D44813945C31 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-368-HrPKTzTRPGCKIcjWbBrP2Q-1; Fri, 12 Feb 2021 09:46:00 -0500 X-MC-Unique: HrPKTzTRPGCKIcjWbBrP2Q-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F2E041020C3C; Fri, 12 Feb 2021 14:45:53 +0000 (UTC) Received: from localhost (unknown [10.33.36.155]) by smtp.corp.redhat.com (Postfix) with ESMTP id 965C550A8D; Fri, 12 Feb 2021 14:45:53 +0000 (UTC) Date: Fri, 12 Feb 2021 14:45:52 +0000 To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Make test memory_resource work without exceptions and RTTI Message-ID: MIME-Version: 1.0 X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-14.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" libstdc++-v3/ChangeLog: * testsuite/util/testsuite_allocator.h (memory_resource): Remove requirement for RTTI and exceptions to be enabled. Tested powerpc64le-linux. Committed to trunk. commit 0bd242ec5aeffd1fb2a3ee16a2c69afae2aff2ce Author: Jonathan Wakely Date: Fri Feb 12 11:23:28 2021 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 --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(); if (alignment != a->alignment) - throw bad_alignment(); + _S_throw(); #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(); } 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(&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 + 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