* [libstdc++ PATCH] Add support for std::uncaught_exceptions
@ 2015-04-12 23:24 Ville Voutilainen
2015-04-13 8:29 ` Jonathan Wakely
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Ville Voutilainen @ 2015-04-12 23:24 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 729 bytes --]
The patch is a bit large since it does the baseline_symbols regeneration
and other new-version api-dance.
Hence attached gzipped.
Tested on Linux x86-64.
2015-04-13 Ville Voutilainen <ville.voutilainen@gmail.com>
Add support for std::uncaught_exceptions.
* acinclude.m4: Bump libtool_VERSION.
* config/abi/post/x86_64-linux-gnu/baseline_symbols.txt: Regenerate.
* config/abi/pre/gnu.ver: Export the new symbol.
* configure: Bump libtool_VERSION.
* libsupc++/eh_catch.cc(uncaught_exceptions): New.
* libsupc++/exception(uncaught_exceptions): Ditto.
* testsuite/18_support/uncaught_exceptions/uncaught_exceptions.cc: New.
* testsuite/util/testsuite_abi.cc: Add 3.4.22 as the latest version.
[-- Attachment #2: uncaught_exceptions.diff.gz --]
[-- Type: application/x-gzip, Size: 19099 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [libstdc++ PATCH] Add support for std::uncaught_exceptions
2015-04-12 23:24 [libstdc++ PATCH] Add support for std::uncaught_exceptions Ville Voutilainen
@ 2015-04-13 8:29 ` Jonathan Wakely
2015-04-15 17:10 ` Daniel Gutson
2015-04-27 20:40 ` Jonathan Wakely
2 siblings, 0 replies; 7+ messages in thread
From: Jonathan Wakely @ 2015-04-13 8:29 UTC (permalink / raw)
To: Ville Voutilainen; +Cc: libstdc++, gcc-patches
On 13 April 2015 at 00:24, Ville Voutilainen wrote:
> The patch is a bit large since it does the baseline_symbols regeneration
That has been done on the trunk now.
> and other new-version api-dance.
Thanks, it'll have to wait until after 5.1 is released, as testing any
last minute fixes will be harder if we've already bumped the symbols
versions on trunk.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [libstdc++ PATCH] Add support for std::uncaught_exceptions
2015-04-12 23:24 [libstdc++ PATCH] Add support for std::uncaught_exceptions Ville Voutilainen
2015-04-13 8:29 ` Jonathan Wakely
@ 2015-04-15 17:10 ` Daniel Gutson
2015-04-16 14:57 ` Jonathan Wakely
2015-04-27 20:40 ` Jonathan Wakely
2 siblings, 1 reply; 7+ messages in thread
From: Daniel Gutson @ 2015-04-15 17:10 UTC (permalink / raw)
To: Ville Voutilainen; +Cc: libstdc++, gcc-patches, Federico Lenarduzzi
Hi Ville,
On Sun, Apr 12, 2015 at 8:24 PM, Ville Voutilainen
<ville.voutilainen@gmail.com> wrote:
> The patch is a bit large since it does the baseline_symbols regeneration
> and other new-version api-dance.
> Hence attached gzipped.
>
> Tested on Linux x86-64.
>
> 2015-04-13 Ville Voutilainen <ville.voutilainen@gmail.com>
> Add support for std::uncaught_exceptions.
> * acinclude.m4: Bump libtool_VERSION.
> * config/abi/post/x86_64-linux-gnu/baseline_symbols.txt: Regenerate.
> * config/abi/pre/gnu.ver: Export the new symbol.
> * configure: Bump libtool_VERSION.
> * libsupc++/eh_catch.cc(uncaught_exceptions): New.
You might want to check this thread
https://gcc.gnu.org/ml/libstdc++/2015-04/msg00104.html
which is specially useful when creating multilibs with and without exceptions
and enabling linker's sections garbage collection.
Maybe you could commit the change for both uncaught_exception and
uncaught_exceptions?
Daniel.
> * libsupc++/exception(uncaught_exceptions): Ditto.
> * testsuite/18_support/uncaught_exceptions/uncaught_exceptions.cc: New.
> * testsuite/util/testsuite_abi.cc: Add 3.4.22 as the latest version.
--
Daniel F. Gutson
Chief Engineering Officer, SPD
San Lorenzo 47, 3rd Floor, Office 5
Córdoba, Argentina
Phone: +54 351 4217888 / +54 351 4218211
Skype: dgutson
LinkedIn: http://ar.linkedin.com/in/danielgutson
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [libstdc++ PATCH] Add support for std::uncaught_exceptions
2015-04-15 17:10 ` Daniel Gutson
@ 2015-04-16 14:57 ` Jonathan Wakely
0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Wakely @ 2015-04-16 14:57 UTC (permalink / raw)
To: Daniel Gutson
Cc: Ville Voutilainen, libstdc++, gcc-patches, Federico Lenarduzzi
On 15/04/15 14:10 -0300, Daniel Gutson wrote:
>You might want to check this thread
>https://gcc.gnu.org/ml/libstdc++/2015-04/msg00104.html
>which is specially useful when creating multilibs with and without exceptions
>and enabling linker's sections garbage collection.
>Maybe you could commit the change for both uncaught_exception and
>uncaught_exceptions?
I'll be doing both commits.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [libstdc++ PATCH] Add support for std::uncaught_exceptions
2015-04-12 23:24 [libstdc++ PATCH] Add support for std::uncaught_exceptions Ville Voutilainen
2015-04-13 8:29 ` Jonathan Wakely
2015-04-15 17:10 ` Daniel Gutson
@ 2015-04-27 20:40 ` Jonathan Wakely
2015-04-27 20:53 ` Jonathan Wakely
2 siblings, 1 reply; 7+ messages in thread
From: Jonathan Wakely @ 2015-04-27 20:40 UTC (permalink / raw)
To: Ville Voutilainen; +Cc: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 1154 bytes --]
On 13/04/15 02:24 +0300, Ville Voutilainen wrote:
>The patch is a bit large since it does the baseline_symbols regeneration
>and other new-version api-dance.
>Hence attached gzipped.
>
>Tested on Linux x86-64.
>
>2015-04-13 Ville Voutilainen <ville.voutilainen@gmail.com>
> Add support for std::uncaught_exceptions.
> * acinclude.m4: Bump libtool_VERSION.
> * config/abi/post/x86_64-linux-gnu/baseline_symbols.txt: Regenerate.
> * config/abi/pre/gnu.ver: Export the new symbol.
> * configure: Bump libtool_VERSION.
> * libsupc++/eh_catch.cc(uncaught_exceptions): New.
> * libsupc++/exception(uncaught_exceptions): Ditto.
> * testsuite/18_support/uncaught_exceptions/uncaught_exceptions.cc: New.
> * testsuite/util/testsuite_abi.cc: Add 3.4.22 as the latest version.
Tested x86_64-linux and powerpc64le-linux. Committed to trunk.
The baseline_symbols changes aren't needed now and I tweaked the
gnu.ver file slightly.
I also added the feature-test macro recommended by N4440 and changed
the new function to only be declared for -std=gnu++?? and -std=c++1z.
It's useful and easy to provide it for pre-C++17 as an extension.
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 7619 bytes --]
commit c37d380f6eea816886147001e0e85932f02b756f
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Mon Apr 27 20:46:03 2015 +0100
2015-04-27 Ville Voutilainen <ville.voutilainen@gmail.com>
Add support for std::uncaught_exceptions.
* acinclude.m4: Bump libtool_VERSION.
* config/abi/pre/gnu.ver: Export the new symbol.
* configure: Regenerate.
* libsupc++/eh_catch.cc (uncaught_exceptions): New.
* libsupc++/exception (uncaught_exceptions): New.
* testsuite/18_support/uncaught_exceptions/uncaught_exceptions.cc: New.
* testsuite/util/testsuite_abi.cc: Add 3.4.22 as the latest version.
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index a1e301f..196b4ff 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -3383,7 +3383,7 @@ changequote([,])dnl
fi
# For libtool versioning info, format is CURRENT:REVISION:AGE
-libtool_VERSION=6:21:0
+libtool_VERSION=6:22:0
# Everything parsed; figure out what files and settings to use.
case $enable_symvers in
diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index 7b82ce8..4ed683c 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -178,7 +178,6 @@ GLIBCXX_3.4 {
# std::[A-Zu-z]*;
# std::underflow_error::u*;
# std::underflow_error::~u*;
- std::uncaught_exception*;
std::unexpected*;
std::[A-Zv-z]*;
std::_List_node_base::hook*;
@@ -1024,6 +1023,9 @@ GLIBCXX_3.4 {
_ZNSt6locale5_Impl19_M_replace_categoryEPKS0_PKPKNS_2idE;
_ZNSt6locale5_Impl21_M_replace_categoriesEPKS0_i;
+ # std::uncaught_exception()
+ _ZSt18uncaught_exceptionv;
+
# DO NOT DELETE THIS LINE. Port-specific symbols, if any, will be here.
local:
@@ -1860,6 +1862,12 @@ GLIBCXX_3.4.21 {
} GLIBCXX_3.4.20;
+GLIBCXX_3.4.22 {
+
+ # std::uncaught_exception()
+ _ZSt19uncaught_exceptionsv;
+
+} GLIBCXX_3.4.21;
# Symbols in the support library (libsupc++) have their own tag.
CXXABI_1.3 {
diff --git a/libstdc++-v3/libsupc++/eh_catch.cc b/libstdc++-v3/libsupc++/eh_catch.cc
index 6302465..723ae56 100644
--- a/libstdc++-v3/libsupc++/eh_catch.cc
+++ b/libstdc++-v3/libsupc++/eh_catch.cc
@@ -139,3 +139,10 @@ std::uncaught_exception() throw()
__cxa_eh_globals *globals = __cxa_get_globals ();
return globals->uncaughtExceptions != 0;
}
+
+int
+std::uncaught_exceptions() throw()
+{
+ __cxa_eh_globals *globals = __cxa_get_globals ();
+ return globals->uncaughtExceptions;
+}
diff --git a/libstdc++-v3/libsupc++/exception b/libstdc++-v3/libsupc++/exception
index d6c1855..069b33c 100644
--- a/libstdc++-v3/libsupc++/exception
+++ b/libstdc++-v3/libsupc++/exception
@@ -126,6 +126,11 @@ namespace std
*/
bool uncaught_exception() _GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__));
+#if !defined(__STRICT_ANSI__) || __cplusplus > 201402L
+#define __cpp_lib_uncaught_exceptions 201411
+ int uncaught_exceptions() _GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__));
+#endif
+
// @} group exceptions
} // namespace std
diff --git a/libstdc++-v3/testsuite/18_support/uncaught_exceptions/uncaught_exceptions.cc b/libstdc++-v3/testsuite/18_support/uncaught_exceptions/uncaught_exceptions.cc
new file mode 100644
index 0000000..001903e
--- /dev/null
+++ b/libstdc++-v3/testsuite/18_support/uncaught_exceptions/uncaught_exceptions.cc
@@ -0,0 +1,162 @@
+// Copyright (C) 2015 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++11" }
+
+#include <cassert>
+#include <exception>
+#include <testsuite_hooks.h>
+
+struct UncaughtVerifier
+{
+ int expected_count_ = 0;
+ UncaughtVerifier(int expected_count) : expected_count_(expected_count) {}
+ ~UncaughtVerifier()
+ {
+ VERIFY(std::uncaught_exceptions() == expected_count_);
+ }
+};
+
+struct Transaction
+{
+ int initial_count_;
+ bool& result_;
+ Transaction(bool& result)
+ : initial_count_(std::uncaught_exceptions()),
+ result_(result) {}
+ ~Transaction()
+ {
+ if (std::uncaught_exceptions() != initial_count_) {
+ result_ = false;
+ }
+ }
+};
+
+void test01()
+{
+ try {
+ UncaughtVerifier uv{0};
+ } catch (...) {
+ UncaughtVerifier uv{0};
+ }
+}
+
+void test02()
+{
+ try {
+ UncaughtVerifier uv{1};
+ throw 0;
+ } catch (...) {
+ UncaughtVerifier uv{0};
+ }
+}
+
+void test03()
+{
+ try {
+ struct Wrap
+ {
+ UncaughtVerifier uv_{1};
+ ~Wrap() {try {UncaughtVerifier uv2{2}; throw 0;} catch(...) {}}
+ };
+ Wrap w;
+ throw 0;
+ } catch (...) {
+ UncaughtVerifier uv{0};
+ }
+}
+
+void test04()
+{
+ bool result = true;
+ try {
+ Transaction t{result};
+ } catch(...) {
+ }
+ VERIFY(result);
+}
+
+void test05()
+{
+ bool result = true;
+ try {
+ Transaction t{result};
+ throw 0;
+ } catch(...) {
+ }
+ VERIFY(!result);
+}
+
+void test06()
+{
+ bool result = true;
+ bool result2 = true;
+ try {
+ struct Wrap
+ {
+ bool& result_;
+ Wrap(bool& result) : result_(result) {}
+ ~Wrap()
+ {
+ Transaction t{result_};
+ }
+ };
+ Transaction t{result};
+ Wrap w{result2};
+ throw 0;
+ } catch(...) {
+ }
+ VERIFY(!result);
+ VERIFY(result2);
+}
+
+void test07()
+{
+ bool result = true;
+ bool result2 = true;
+ try {
+ struct Wrap
+ {
+ bool& result_;
+ Wrap(bool& result) : result_(result) {}
+ ~Wrap()
+ {
+ try {
+ Transaction t{result_};
+ throw 0;
+ } catch(...) {}
+ }
+ };
+ Transaction t{result};
+ Wrap w{result2};
+ throw 0;
+ } catch(...) {
+ }
+ VERIFY(!result);
+ VERIFY(!result2);
+}
+
+int main()
+{
+ test01();
+ test02();
+ test03();
+ test04();
+ test05();
+ test06();
+ test07();
+}
diff --git a/libstdc++-v3/testsuite/util/testsuite_abi.cc b/libstdc++-v3/testsuite/util/testsuite_abi.cc
index 116caad..7b76b68 100644
--- a/libstdc++-v3/testsuite/util/testsuite_abi.cc
+++ b/libstdc++-v3/testsuite/util/testsuite_abi.cc
@@ -201,6 +201,7 @@ check_version(symbol& test, bool added)
known_versions.push_back("GLIBCXX_3.4.19");
known_versions.push_back("GLIBCXX_3.4.20");
known_versions.push_back("GLIBCXX_3.4.21");
+ known_versions.push_back("GLIBCXX_3.4.22");
known_versions.push_back("GLIBCXX_LDBL_3.4.21");
known_versions.push_back("CXXABI_1.3");
known_versions.push_back("CXXABI_LDBL_1.3");
@@ -230,7 +231,7 @@ check_version(symbol& test, bool added)
test.version_status = symbol::incompatible;
// Check that added symbols are added in the latest pre-release version.
- bool latestp = (test.version_name == "GLIBCXX_3.4.21"
+ bool latestp = (test.version_name == "GLIBCXX_3.4.22"
|| test.version_name == "CXXABI_1.3.9"
|| test.version_name == "CXXABI_FLOAT128"
|| test.version_name == "CXXABI_TM_1");
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [libstdc++ PATCH] Add support for std::uncaught_exceptions
2015-04-27 20:40 ` Jonathan Wakely
@ 2015-04-27 20:53 ` Jonathan Wakely
2015-04-28 12:36 ` Jonathan Wakely
0 siblings, 1 reply; 7+ messages in thread
From: Jonathan Wakely @ 2015-04-27 20:53 UTC (permalink / raw)
To: Ville Voutilainen; +Cc: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 263 bytes --]
On 27/04/15 21:40 +0100, Jonathan Wakely wrote:
>Tested x86_64-linux and powerpc64le-linux. Committed to trunk.
>
>The baseline_symbols changes aren't needed now and I tweaked the
>gnu.ver file slightly.
Ville noticed a typo in a comment I added, fixed like so.
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 631 bytes --]
commit c595cfa88c9d38f333b262635a1c32744e3ce054
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Mon Apr 27 21:51:53 2015 +0100
2015-04-27 Ville Voutilainen <ville.voutilainen@gmail.com>
* config/abi/pre/gnu.ver: Fix comment.
diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index 4ed683c..2da04e4 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -1864,7 +1864,7 @@ GLIBCXX_3.4.21 {
GLIBCXX_3.4.22 {
- # std::uncaught_exception()
+ # std::uncaught_exceptions()
_ZSt19uncaught_exceptionsv;
} GLIBCXX_3.4.21;
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [libstdc++ PATCH] Add support for std::uncaught_exceptions
2015-04-27 20:53 ` Jonathan Wakely
@ 2015-04-28 12:36 ` Jonathan Wakely
0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Wakely @ 2015-04-28 12:36 UTC (permalink / raw)
To: Ville Voutilainen; +Cc: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 448 bytes --]
On 27/04/15 21:53 +0100, Jonathan Wakely wrote:
>On 27/04/15 21:40 +0100, Jonathan Wakely wrote:
>>Tested x86_64-linux and powerpc64le-linux. Committed to trunk.
>>
>>The baseline_symbols changes aren't needed now and I tweaked the
>>gnu.ver file slightly.
>
>Ville noticed a typo in a comment I added, fixed like so.
One further tweak to add a doxygen comment and test the feature-test
macro is correct.
Tested x86_64-linux, committed to trunk.
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 1860 bytes --]
commit 735307c6ba52a958da314aca09a1bf8ca8210a63
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Mon Apr 27 22:33:26 2015 +0100
* libsupc++/exception (uncaught_exceptions): Add comment. Reorder #if.
* testsuite/18_support/uncaught_exceptions/uncaught_exceptions.cc:
Use -std=gnu++1z. Check feature-test macro.
diff --git a/libstdc++-v3/libsupc++/exception b/libstdc++-v3/libsupc++/exception
index 069b33c..5571fd9 100644
--- a/libstdc++-v3/libsupc++/exception
+++ b/libstdc++-v3/libsupc++/exception
@@ -126,8 +126,9 @@ namespace std
*/
bool uncaught_exception() _GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__));
-#if !defined(__STRICT_ANSI__) || __cplusplus > 201402L
+#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++98
#define __cpp_lib_uncaught_exceptions 201411
+ /// The number of uncaught exceptions.
int uncaught_exceptions() _GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__));
#endif
diff --git a/libstdc++-v3/testsuite/18_support/uncaught_exceptions/uncaught_exceptions.cc b/libstdc++-v3/testsuite/18_support/uncaught_exceptions/uncaught_exceptions.cc
index 001903e..c65da5f 100644
--- a/libstdc++-v3/testsuite/18_support/uncaught_exceptions/uncaught_exceptions.cc
+++ b/libstdc++-v3/testsuite/18_support/uncaught_exceptions/uncaught_exceptions.cc
@@ -15,12 +15,18 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// { dg-options "-std=gnu++11" }
+// { dg-options "-std=gnu++1z" }
#include <cassert>
#include <exception>
#include <testsuite_hooks.h>
+#ifndef __cpp_lib_uncaught_exceptions
+# error "Feature-test macro for uncaught_exceptions missing"
+#elif __cpp_lib_uncaught_exceptions != 201411
+# error "Feature-test macro for uncaught_exceptions has wrong value"
+#endif
+
struct UncaughtVerifier
{
int expected_count_ = 0;
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-04-28 12:09 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-12 23:24 [libstdc++ PATCH] Add support for std::uncaught_exceptions Ville Voutilainen
2015-04-13 8:29 ` Jonathan Wakely
2015-04-15 17:10 ` Daniel Gutson
2015-04-16 14:57 ` Jonathan Wakely
2015-04-27 20:40 ` Jonathan Wakely
2015-04-27 20:53 ` Jonathan Wakely
2015-04-28 12:36 ` Jonathan Wakely
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).