From 5b89cf209c3fb184a917355e12f589c83e9ad28f Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 22 Jun 2018 18:32:12 +0300 Subject: Use uncaught_exceptions() if available C++17 deprecated uncaught_exception() and GCC 8 now issues a warning. --- mod/diagnostics.cxx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'mod/diagnostics.cxx') 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 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. -- cgit v1.1