From patchwork Fri May 13 20:01:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 53975 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5F2D2398640C for ; Fri, 13 May 2022 20:03:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5F2D2398640C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1652472221; bh=sccYFBcmxxIgSpO9Gkhs7Z4+j6+etdciUkJStyl1czI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ZN/0odVWpWtHxeyyH1DBDkOWfpIZwfbne9JrYvy19fVCRmv0s6tLNK3IynNNRA6od nvTcAxOpT29V98XiMO/6KtWlwOP707j60OHE82gb2ythaKRBNvd5G9IpmJiaDGKdw3 ZEo9hTvRRcdnlpw7BbthYGyEwkwhuJ4xhEW6N2Hg= 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 [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 2EFF5398642D for ; Fri, 13 May 2022 20:01:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2EFF5398642D Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-207-kHYXH7AWMQmmnMkzPDqAPg-1; Fri, 13 May 2022 16:01:09 -0400 X-MC-Unique: kHYXH7AWMQmmnMkzPDqAPg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5EB86800B21; Fri, 13 May 2022 20:01:09 +0000 (UTC) Received: from localhost (unknown [10.33.36.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 252B12026E03; Fri, 13 May 2022 20:01:09 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Allow std::swap to find overload for std::exception_ptr Date: Fri, 13 May 2022 21:01:08 +0100 Message-Id: <20220513200108.4138669-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.4 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, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Tested powerpc64l4-linux, pushed to trunk. -- >8 -- The non-member swap for std::exception_ptr is in a nested namespace and so can only be found by ADL currently. Add a using-declaration so that qualified std::swap calls will use the std::exception_ptr::swap member, instead of the generic std::swap. There's no new test for this, because the generic std::swap works, it just does more work than is necessary. Also tell Doxygen to replace the __exception_ptr namespace with "__unspecified__" in the generate docs, so the real name is not documented. libstdc++-v3/ChangeLog: * doc/doxygen/user.cfg.in (PREDEFINED): Replace __exception_ptr with "__unspecified__". * libsupc++/exception_ptr.h: Improve doxygen docs. (__exception_ptr::swap): Also declare in namespace std. --- libstdc++-v3/doc/doxygen/user.cfg.in | 1 + libstdc++-v3/libsupc++/exception_ptr.h | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/doc/doxygen/user.cfg.in b/libstdc++-v3/doc/doxygen/user.cfg.in index c034b864928..57270bdeb7a 100644 --- a/libstdc++-v3/doc/doxygen/user.cfg.in +++ b/libstdc++-v3/doc/doxygen/user.cfg.in @@ -2408,6 +2408,7 @@ PREDEFINED = __cplusplus=202002L \ _GLIBCXX_HAVE_BUILTIN_LAUNDER \ "_GLIBCXX_DOXYGEN_ONLY(X)=X " \ __allocator_base=std::__new_allocator \ + __exception_ptr=__unspecified__ \ # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The diff --git a/libstdc++-v3/libsupc++/exception_ptr.h b/libstdc++-v3/libsupc++/exception_ptr.h index 21c53f686ba..fd9ceec88d4 100644 --- a/libstdc++-v3/libsupc++/exception_ptr.h +++ b/libstdc++-v3/libsupc++/exception_ptr.h @@ -65,9 +65,12 @@ namespace std _GLIBCXX_VISIBILITY(default) using __exception_ptr::exception_ptr; - /** Obtain an exception_ptr to the currently handled exception. If there - * is none, or the currently handled exception is foreign, return the null - * value. + /** Obtain an exception_ptr to the currently handled exception. + * + * If there is none, or the currently handled exception is foreign, + * return the null value. + * + * @since C++11 */ exception_ptr current_exception() _GLIBCXX_USE_NOEXCEPT; @@ -79,10 +82,16 @@ namespace std _GLIBCXX_VISIBILITY(default) namespace __exception_ptr { - using std::rethrow_exception; + using std::rethrow_exception; // So that ADL finds it. /** * @brief An opaque pointer to an arbitrary exception. + * + * The actual name of this type is unspecified, so the alias + * `std::exception_ptr` should be used to refer to it. + * + * @headerfile exception + * @since C++11 (but usable in C++98 as a GCC extension) * @ingroup exceptions */ class exception_ptr @@ -231,6 +240,8 @@ namespace std _GLIBCXX_VISIBILITY(default) } // namespace __exception_ptr + using __exception_ptr::swap; // So that std::swap(exp1, exp2) finds it. + /// Obtain an exception_ptr pointing to a copy of the supplied object. #if (__cplusplus >= 201103L && __cpp_rtti) || __cpp_exceptions template