aboutsummaryrefslogtreecommitdiff
path: root/mod/diagnostics.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-06-22 18:32:12 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-06-22 18:32:33 +0300
commit5b89cf209c3fb184a917355e12f589c83e9ad28f (patch)
tree93f6acee315c8813494b2fd1b038add89c716d43 /mod/diagnostics.cxx
parent98fd9c8729081139a9942d5f4e8adf2d1754f330 (diff)
Use uncaught_exceptions() if available
C++17 deprecated uncaught_exception() and GCC 8 now issues a warning.
Diffstat (limited to 'mod/diagnostics.cxx')
-rw-r--r--mod/diagnostics.cxx17
1 files changed, 11 insertions, 6 deletions
diff --git a/mod/diagnostics.cxx b/mod/diagnostics.cxx
index 07fd86c..601ecab 100644
--- a/mod/diagnostics.cxx
+++ b/mod/diagnostics.cxx
@@ -5,6 +5,7 @@
#include <mod/diagnostics.hxx>
using namespace std;
+using namespace butl;
namespace brep
{
@@ -12,14 +13,18 @@ namespace brep
~diag_record () noexcept(false)
{
// Don't flush the record if this destructor was called as part of
- // the stack unwinding. Right now this means we cannot use this
- // mechanism in destructors, which is not a big deal, except for
- // one place: exception_guard. So for now we are going to have
- // this ugly special check which we will be able to get rid of
- // once C++17 uncaught_exceptions() becomes available.
+ // the stack unwinding.
+ //
+#ifdef __cpp_lib_uncaught_exceptions
+ if (!data_.empty () && uncaught_ == uncaught_exceptions ())
+#else
+ // Fallback implementation. Right now this means we cannot use this
+ // mechanism in destructors, which is not a big deal, except for one
+ // place: exception_guard. Thus the ugly special check.
//
if (!data_.empty () &&
- (!uncaught_exception () /*|| exception_unwinding_dtor*/))
+ (!uncaught_exception () || exception_unwinding_dtor ()))
+#endif
{
data_.back ().msg = os_.str (); // Save last message.