diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..db7251b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,30 @@ +# Copyright 2019 Mike Dev +# Distributed under the Boost Software License, Version 1.0. +# See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt +# +# NOTE: CMake support for Boost.Exception is currently experimental at best +# and the interface is likely to change in the future + +cmake_minimum_required( VERSION 3.5 ) +project( BoostException LANGUAGES CXX ) + +# We treat Boost.Exception as header only for now. +# See https://github.com/boostorg/exception/pull/17 +# for more information. + +add_library( boost_exception INTERFACE ) +add_library( Boost::exception ALIAS boost_exception ) + +target_include_directories( boost_exception INTERFACE include ) + +target_link_libraries( boost_exception + INTERFACE + Boost::assert + Boost::config + Boost::core + Boost::smart_ptr + Boost::throw_exception + Boost::tuple + Boost::type_traits +) + diff --git a/example/example_io.cpp b/example/example_io.cpp index 09b6138..f489332 100644 --- a/example/example_io.cpp +++ b/example/example_io.cpp @@ -35,14 +35,14 @@ error: //Base for all exception objects we throw. public: char const * - what() const throw() + what() const BOOST_NOEXCEPT_OR_NOTHROW { return "example_io error"; } protected: - ~error() throw() + ~error() BOOST_NOEXCEPT_OR_NOTHROW { } }; diff --git a/include/boost/exception/detail/error_info_impl.hpp b/include/boost/exception/detail/error_info_impl.hpp index 6c48d61..bef7fd8 100644 --- a/include/boost/exception/detail/error_info_impl.hpp +++ b/include/boost/exception/detail/error_info_impl.hpp @@ -35,7 +35,7 @@ boost virtual error_info_base * clone() const = 0; virtual - ~error_info_base() throw() + ~error_info_base() BOOST_NOEXCEPT_OR_NOTHROW { } }; @@ -46,7 +46,7 @@ boost error_info: public exception_detail::error_info_base { - error_info_base * + exception_detail::error_info_base * clone() const { return new error_info(*this); @@ -73,7 +73,7 @@ boost } #endif #endif - ~error_info() throw() + ~error_info() BOOST_NOEXCEPT_OR_NOTHROW { } value_type const & diff --git a/include/boost/exception/detail/exception_ptr.hpp b/include/boost/exception/detail/exception_ptr.hpp index 8e19f0d..a7f0a25 100644 --- a/include/boost/exception/detail/exception_ptr.hpp +++ b/include/boost/exception/detail/exception_ptr.hpp @@ -105,7 +105,7 @@ boost boost::exception, std::bad_alloc { - ~bad_alloc_() throw() { } + ~bad_alloc_() BOOST_NOEXCEPT_OR_NOTHROW { } }; struct @@ -113,7 +113,7 @@ boost boost::exception, std::bad_exception { - ~bad_exception_() throw() { } + ~bad_exception_() BOOST_NOEXCEPT_OR_NOTHROW { } }; template @@ -174,7 +174,7 @@ boost add_original_type(e); } - ~unknown_exception() throw() + ~unknown_exception() BOOST_NOEXCEPT_OR_NOTHROW { } @@ -220,7 +220,7 @@ boost add_original_type(e1); } - ~current_exception_std_exception_wrapper() throw() + ~current_exception_std_exception_wrapper() BOOST_NOEXCEPT_OR_NOTHROW { } diff --git a/include/boost/exception/diagnostic_information.hpp b/include/boost/exception/diagnostic_information.hpp index 48f06a0..ad22735 100644 --- a/include/boost/exception/diagnostic_information.hpp +++ b/include/boost/exception/diagnostic_information.hpp @@ -45,6 +45,10 @@ boost std::exception const * se=current_exception_cast(); if( be || se ) return exception_detail::diagnostic_information_impl(be,se,true,verbose); +#if defined(__GLIBCXX__) && __cplusplus >= 201103L && !defined(BOOST_NO_RTTI) + else if (auto* p=std::current_exception().__cxa_exception_type()) + return "Dynamic exception type: "+boost::core::demangle(p->name()); +#endif else return "No diagnostic information available."; } @@ -157,7 +161,7 @@ boost core::demangle((be?(BOOST_EXCEPTION_DYNAMIC_TYPEID(*be)):(BOOST_EXCEPTION_DYNAMIC_TYPEID(*se))).type_->name()) << '\n'; #endif if( with_what && se && verbose ) - tmp << "std::exception::what: " << wh << '\n'; + tmp << "std::exception::what: " << (wh ? wh : "(null)") << '\n'; if( be ) if( char const * s=exception_detail::get_diagnostic_information(*be,tmp.str().c_str()) ) if( *s ) @@ -175,7 +179,7 @@ boost inline char const * - diagnostic_information_what( exception const & e, bool verbose=true ) throw() + diagnostic_information_what( exception const & e, bool verbose=true ) BOOST_NOEXCEPT_OR_NOTHROW { char const * w=0; #ifndef BOOST_NO_EXCEPTIONS diff --git a/include/boost/exception/info.hpp b/include/boost/exception/info.hpp index f7ac50e..5e3ad52 100644 --- a/include/boost/exception/info.hpp +++ b/include/boost/exception/info.hpp @@ -62,7 +62,7 @@ boost { } - ~error_info_container_impl() throw() + ~error_info_container_impl() BOOST_NOEXCEPT_OR_NOTHROW { } diff --git a/src/clone_current_exception_non_intrusive.cpp b/src/clone_current_exception_non_intrusive.cpp index 7ebd7b5..932bca8 100644 --- a/src/clone_current_exception_non_intrusive.cpp +++ b/src/clone_current_exception_non_intrusive.cpp @@ -230,7 +230,7 @@ namespace { } - ~cloned_exception() throw() + ~cloned_exception() BOOST_NOEXCEPT_OR_NOTHROW { } diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index df85359..2b4cad8 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -71,3 +71,5 @@ compile errinfo_file_name_hpp_test.cpp ; compile errinfo_file_open_mode_hpp_test.cpp ; compile errinfo_nested_exception_hpp_test.cpp ; compile errinfo_type_info_name_hpp_test.cpp ; + +compile bug_11874_test.cpp ; diff --git a/test/bug_11874_test.cpp b/test/bug_11874_test.cpp new file mode 100644 index 0000000..3d8fd4a --- /dev/null +++ b/test/bug_11874_test.cpp @@ -0,0 +1,10 @@ +//Copyright (c) 2006-2017 Emil Dotchevski and Reverge Studios, Inc. + +//Distributed under the Boost Software License, Version 1.0. (See accompanying +//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#include + +int main() +{ +} diff --git a/test/cloning_test.cpp b/test/cloning_test.cpp index c5a4ae9..138a38c 100644 --- a/test/cloning_test.cpp +++ b/test/cloning_test.cpp @@ -73,7 +73,7 @@ derives_std_boost_exception: { } - char const * what() const throw() + char const * what() const BOOST_NOEXCEPT_OR_NOTHROW { return wh_; } diff --git a/test/copy_exception_test.cpp b/test/copy_exception_test.cpp index a88e6d5..69acb65 100644 --- a/test/copy_exception_test.cpp +++ b/test/copy_exception_test.cpp @@ -29,7 +29,7 @@ err: } virtual - ~err() throw() + ~err() BOOST_NOEXCEPT_OR_NOTHROW { --exc_count; } diff --git a/test/diagnostic_information_test.cpp b/test/diagnostic_information_test.cpp index 05ec554..35eb5e8 100644 --- a/test/diagnostic_information_test.cpp +++ b/test/diagnostic_information_test.cpp @@ -28,7 +28,7 @@ error1: boost::exception { char const * - what() const throw() + what() const BOOST_NOEXCEPT_OR_NOTHROW { return "error1"; } @@ -45,7 +45,7 @@ error3: std::exception { char const * - what() const throw() + what() const BOOST_NOEXCEPT_OR_NOTHROW { return "error3"; } @@ -57,7 +57,7 @@ error4: boost::exception { char const * - what() const throw() + what() const BOOST_NOEXCEPT_OR_NOTHROW { return diagnostic_information_what(*this); } diff --git a/test/exception_ptr_test.cpp b/test/exception_ptr_test.cpp index 367558c..ebcb1d5 100644 --- a/test/exception_ptr_test.cpp +++ b/test/exception_ptr_test.cpp @@ -87,7 +87,7 @@ exc: } virtual - ~exc() throw() + ~exc() BOOST_NOEXCEPT_OR_NOTHROW { --exc_count; } diff --git a/test/helper2.cpp b/test/helper2.cpp index 982d084..88809a7 100644 --- a/test/helper2.cpp +++ b/test/helper2.cpp @@ -20,7 +20,7 @@ boost } derives_boost_exception:: - ~derives_boost_exception() throw() + ~derives_boost_exception() BOOST_NOEXCEPT_OR_NOTHROW { } @@ -32,7 +32,7 @@ boost } derives_boost_exception_virtually:: - ~derives_boost_exception_virtually() throw() + ~derives_boost_exception_virtually() BOOST_NOEXCEPT_OR_NOTHROW { } @@ -44,7 +44,7 @@ boost } derives_std_exception:: - ~derives_std_exception() throw() + ~derives_std_exception() BOOST_NOEXCEPT_OR_NOTHROW { } diff --git a/test/helper2.hpp b/test/helper2.hpp index 0708476..885eee5 100644 --- a/test/helper2.hpp +++ b/test/helper2.hpp @@ -21,7 +21,7 @@ boost public std::exception { explicit derives_boost_exception( int x ); - virtual ~derives_boost_exception() throw(); + virtual ~derives_boost_exception() BOOST_NOEXCEPT_OR_NOTHROW; int x_; }; @@ -31,7 +31,7 @@ boost public std::exception { explicit derives_boost_exception_virtually( int x ); - virtual ~derives_boost_exception_virtually() throw(); + virtual ~derives_boost_exception_virtually() BOOST_NOEXCEPT_OR_NOTHROW; int x_; }; @@ -40,7 +40,7 @@ boost public std::exception { explicit derives_std_exception( int x ); - virtual ~derives_std_exception() throw(); + virtual ~derives_std_exception() BOOST_NOEXCEPT_OR_NOTHROW; int x_; }; diff --git a/test/no_exceptions_test.cpp b/test/no_exceptions_test.cpp index d335fb6..2e8665a 100644 --- a/test/no_exceptions_test.cpp +++ b/test/no_exceptions_test.cpp @@ -17,7 +17,7 @@ my_exception: std::exception { char const * - what() const throw() + what() const BOOST_NOEXCEPT_OR_NOTHROW { return "my_exception"; }