From patchwork Wed Apr 24 22:00:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 239325 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 8ACD32C00D0 for ; Thu, 25 Apr 2013 08:00:47 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; q= dns; s=default; b=VXX3GTU7p5gnpJt+hw1LZjb+/0XUfD6CNsK9QNU5gP1JNM FqVTOk6aXR1Ki1ajWX3Jcybxi+a6oF7Lc+FFnM+GuEVGqPKJXhjFDdYaoDy5PwVH wrZx+1LpxqxcSioxfllpRF0C+zXz8ZGfm6NSUvRniehvh1pgxZq0CR09ykDYE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; s= default; bh=20KeGAcMtdDnyxVRCqcxEbY4RRU=; b=lywUZgJ9il0Lb2mMww9o cRiV5dxiiBEqsGfkPGrEFP/73bBO+F0Ij1sbgIbd+kEAoMeJgK6Kwqh3noNp+rrD YfkLFmtW96ZcT3au3rLKZ9e2DhJiDGKTTWHjNHWzymMifZXSdyk59vEJT/SyqJ7l yu1cDXIGk7p/Tj2RX8iv50E= Received: (qmail 1990 invoked by alias); 24 Apr 2013 22:00:41 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 1970 invoked by uid 89); 24 Apr 2013 22:00:40 -0000 X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, SPF_PASS autolearn=ham version=3.3.1 X-Spam-User: qpsmtpd, 2 recipients Received: from mail-lb0-f176.google.com (HELO mail-lb0-f176.google.com) (209.85.217.176) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 24 Apr 2013 22:00:39 +0000 Received: by mail-lb0-f176.google.com with SMTP id y8so2219951lbh.35 for ; Wed, 24 Apr 2013 15:00:36 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.112.146.34 with SMTP id sz2mr18307931lbb.4.1366840836441; Wed, 24 Apr 2013 15:00:36 -0700 (PDT) Received: by 10.112.166.101 with HTTP; Wed, 24 Apr 2013 15:00:36 -0700 (PDT) Date: Wed, 24 Apr 2013 23:00:36 +0100 Message-ID: Subject: [patch] libstdc++/56905 deprecate copy_exception From: Jonathan Wakely To: "libstdc++" , gcc-patches X-Virus-Found: No The C++0x draft defined std::copy_exception but it was renamed to std::make_exception_ptr in the final C++11 standard. This changes the library to use the new name and deprecates the old one, so we can remove it one day. PR libstdc++/56905 * libsupc++/exception_ptr.h (copy_exception): Deprecate and move implementation to make_exception_ptr. * include/std/future (_State_base::_M_break_promise): Replace copy_exception with make_exception_ptr. * testsuite/18_support/exception_ptr/move.cc: Likewise. * testsuite/18_support/exception_ptr/rethrow_exception.cc: Likewise. * testsuite/30_threads/future/members/get2.cc: Likewise. * testsuite/30_threads/promise/members/set_exception.cc: Likewise. * testsuite/30_threads/promise/members/set_exception2.cc: Likewise. * testsuite/30_threads/promise/members/set_value2.cc: Likewise. * testsuite/30_threads/shared_future/members/get2.cc: Likewise. Tested x86_64-linux, committed to trunk. commit d6085858a53401f853913d9e58337e4a467a7460 Author: Jonathan Wakely Date: Wed Apr 24 22:40:11 2013 +0100 PR libstdc++/56905 * libsupc++/exception_ptr.h (copy_exception): Deprecate and move implementation to make_exception_ptr. * include/std/future (_State_base::_M_break_promise): Replace copy_exception with make_exception_ptr. * testsuite/18_support/exception_ptr/move.cc: Likewise. * testsuite/18_support/exception_ptr/rethrow_exception.cc: Likewise. * testsuite/30_threads/future/members/get2.cc: Likewise. * testsuite/30_threads/promise/members/set_exception.cc: Likewise. * testsuite/30_threads/promise/members/set_exception2.cc: Likewise. * testsuite/30_threads/promise/members/set_value2.cc: Likewise. * testsuite/30_threads/shared_future/members/get2.cc: Likewise. diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future index a86a7ca..6d6b32b 100644 --- a/libstdc++-v3/include/std/future +++ b/libstdc++-v3/include/std/future @@ -361,7 +361,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION if (static_cast(__res)) { error_code __ec(make_error_code(future_errc::broken_promise)); - __res->_M_error = copy_exception(future_error(__ec)); + __res->_M_error = make_exception_ptr(future_error(__ec)); { lock_guard __lock(_M_mutex); _M_result.swap(__res); diff --git a/libstdc++-v3/libsupc++/exception_ptr.h b/libstdc++-v3/libsupc++/exception_ptr.h index bbf8f85..effab347 100644 --- a/libstdc++-v3/libsupc++/exception_ptr.h +++ b/libstdc++-v3/libsupc++/exception_ptr.h @@ -166,7 +166,7 @@ namespace std /// Obtain an exception_ptr pointing to a copy of the supplied object. template exception_ptr - copy_exception(_Ex __ex) _GLIBCXX_USE_NOEXCEPT + make_exception_ptr(_Ex __ex) _GLIBCXX_USE_NOEXCEPT { __try { @@ -183,10 +183,15 @@ namespace std // _GLIBCXX_RESOLVE_LIB_DEFECTS // 1130. copy_exception name misleading /// Obtain an exception_ptr pointing to a copy of the supplied object. + /// This function is deprecated, use std::make_exception_ptr instead. template - exception_ptr - make_exception_ptr(_Ex __ex) _GLIBCXX_USE_NOEXCEPT - { return std::copy_exception<_Ex>(__ex); } + exception_ptr + copy_exception(_Ex __ex) _GLIBCXX_USE_NOEXCEPT _GLIBCXX_DEPRECATED; + + template + exception_ptr + copy_exception(_Ex __ex) _GLIBCXX_USE_NOEXCEPT + { return std::make_exception_ptr<_Ex>(__ex); } // @} group exceptions } // namespace std diff --git a/libstdc++-v3/testsuite/18_support/exception_ptr/move.cc b/libstdc++-v3/testsuite/18_support/exception_ptr/move.cc index 2b7284d..9c3df1e 100644 --- a/libstdc++-v3/testsuite/18_support/exception_ptr/move.cc +++ b/libstdc++-v3/testsuite/18_support/exception_ptr/move.cc @@ -28,7 +28,7 @@ void test01() { bool test = true; - std::exception_ptr p1 = std::copy_exception(test); + std::exception_ptr p1 = std::make_exception_ptr(test); std::exception_ptr p2 = std::move(p1); VERIFY( p1 == 0 ); VERIFY( !(p2 == 0) ); diff --git a/libstdc++-v3/testsuite/18_support/exception_ptr/rethrow_exception.cc b/libstdc++-v3/testsuite/18_support/exception_ptr/rethrow_exception.cc index 430913c..39a57fe 100644 --- a/libstdc++-v3/testsuite/18_support/exception_ptr/rethrow_exception.cc +++ b/libstdc++-v3/testsuite/18_support/exception_ptr/rethrow_exception.cc @@ -34,7 +34,7 @@ void test01() using namespace std; try { - rethrow_exception(copy_exception(0)); + rethrow_exception(make_exception_ptr(0)); } catch(...) { } } @@ -45,7 +45,7 @@ void test02() using namespace std; try { - rethrow_exception(copy_exception(runtime_error("test"))); + rethrow_exception(make_exception_ptr(runtime_error("test"))); } catch(exception &e) { VERIFY( typeid(e) == typeid(runtime_error) ); VERIFY( strcmp(e.what(), "test") == 0 ); diff --git a/libstdc++-v3/testsuite/30_threads/future/members/get2.cc b/libstdc++-v3/testsuite/30_threads/future/members/get2.cc index b74c84d..2f05240 100644 --- a/libstdc++-v3/testsuite/30_threads/future/members/get2.cc +++ b/libstdc++-v3/testsuite/30_threads/future/members/get2.cc @@ -37,7 +37,7 @@ void test01() std::promise p1; std::future f1(p1.get_future()); - p1.set_exception(std::copy_exception(value)); + p1.set_exception(std::make_exception_ptr(value)); try { (void) f1.get(); @@ -57,7 +57,7 @@ void test02() std::promise p1; std::future f1(p1.get_future()); - p1.set_exception(std::copy_exception(value)); + p1.set_exception(std::make_exception_ptr(value)); try { (void) f1.get(); @@ -77,7 +77,7 @@ void test03() std::promise p1; std::future f1(p1.get_future()); - p1.set_exception(std::copy_exception(value)); + p1.set_exception(std::make_exception_ptr(value)); try { f1.get(); diff --git a/libstdc++-v3/testsuite/30_threads/promise/members/set_exception.cc b/libstdc++-v3/testsuite/30_threads/promise/members/set_exception.cc index c7f1df2..920c116 100644 --- a/libstdc++-v3/testsuite/30_threads/promise/members/set_exception.cc +++ b/libstdc++-v3/testsuite/30_threads/promise/members/set_exception.cc @@ -36,7 +36,7 @@ void test01() VERIFY( f1.valid() ); - p1.set_exception(std::copy_exception(0)); + p1.set_exception(std::make_exception_ptr(0)); try { diff --git a/libstdc++-v3/testsuite/30_threads/promise/members/set_exception2.cc b/libstdc++-v3/testsuite/30_threads/promise/members/set_exception2.cc index 527cfbb..84c26d6 100644 --- a/libstdc++-v3/testsuite/30_threads/promise/members/set_exception2.cc +++ b/libstdc++-v3/testsuite/30_threads/promise/members/set_exception2.cc @@ -34,11 +34,11 @@ void test01() std::promise p1; std::future f1 = p1.get_future(); - p1.set_exception(std::copy_exception(0)); + p1.set_exception(std::make_exception_ptr(0)); try { - p1.set_exception(std::copy_exception(1)); + p1.set_exception(std::make_exception_ptr(1)); VERIFY( false ); } catch (std::future_error& e) @@ -72,7 +72,7 @@ void test02() try { - p1.set_exception(std::copy_exception(0)); + p1.set_exception(std::make_exception_ptr(0)); VERIFY( false ); } catch (std::future_error& e) diff --git a/libstdc++-v3/testsuite/30_threads/promise/members/set_value2.cc b/libstdc++-v3/testsuite/30_threads/promise/members/set_value2.cc index fcba745..2ee5987 100644 --- a/libstdc++-v3/testsuite/30_threads/promise/members/set_value2.cc +++ b/libstdc++-v3/testsuite/30_threads/promise/members/set_value2.cc @@ -65,7 +65,7 @@ void test02() try { - p1.set_exception(std::copy_exception(4)); + p1.set_exception(std::make_exception_ptr(4)); VERIFY( false ); } catch (std::future_error& e) diff --git a/libstdc++-v3/testsuite/30_threads/shared_future/members/get2.cc b/libstdc++-v3/testsuite/30_threads/shared_future/members/get2.cc index 1b8ccea..2fed6d5 100644 --- a/libstdc++-v3/testsuite/30_threads/shared_future/members/get2.cc +++ b/libstdc++-v3/testsuite/30_threads/shared_future/members/get2.cc @@ -38,7 +38,7 @@ void test01() std::shared_future f1(p1.get_future()); std::shared_future f2(f1); - p1.set_exception(std::copy_exception(value)); + p1.set_exception(std::make_exception_ptr(value)); try { (void) f1.get(); @@ -67,7 +67,7 @@ void test02() std::shared_future f1(p1.get_future()); std::shared_future f2(f1); - p1.set_exception(std::copy_exception(value)); + p1.set_exception(std::make_exception_ptr(value)); try { (void) f1.get(); @@ -96,7 +96,7 @@ void test03() std::shared_future f1(p1.get_future()); std::shared_future f2(f1); - p1.set_exception(std::copy_exception(value)); + p1.set_exception(std::make_exception_ptr(value)); try { f1.get();