From 1e507924cea8af2c57203549e1e132a6f314c475 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 3 Jun 2019 03:06:40 +0300 Subject: [PATCH] Mark throw_exception with BOOST_NORETURN. Closes #12. --- include/boost/throw_exception.hpp | 2 +- test/throw_exception_no_both_test.cpp | 35 ++++++++++----------- test/throw_exception_no_exceptions_test.cpp | 35 ++++++++++----------- 3 files changed, 33 insertions(+), 39 deletions(-) diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index c6623e1..cd77ead 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -54,7 +54,7 @@ namespace boost { #ifdef BOOST_NO_EXCEPTIONS -void throw_exception( std::exception const & e ); // user defined +BOOST_NORETURN void throw_exception( std::exception const & e ); // user defined #else diff --git a/test/throw_exception_no_both_test.cpp b/test/throw_exception_no_both_test.cpp index 789bb74..b7e673f 100644 --- a/test/throw_exception_no_both_test.cpp +++ b/test/throw_exception_no_both_test.cpp @@ -5,27 +5,24 @@ #define BOOST_NO_EXCEPTIONS #define BOOST_EXCEPTION_DISABLE + #include -#include +#include -class my_exception: public std::exception { }; +class my_exception: public std::exception {}; -bool called=false; +int main() +{ + boost::throw_exception( my_exception() ); + return 1; +} -namespace -boost - { - void - throw_exception( std::exception const & ) - { - called=true; - } - } +namespace boost +{ -int -main() - { - boost::throw_exception(my_exception()); - BOOST_TEST(called); - return boost::report_errors(); - } +void throw_exception( std::exception const & ) +{ + std::exit( 0 ); +} + +} // namespace boost diff --git a/test/throw_exception_no_exceptions_test.cpp b/test/throw_exception_no_exceptions_test.cpp index 91b84b7..467dab5 100644 --- a/test/throw_exception_no_exceptions_test.cpp +++ b/test/throw_exception_no_exceptions_test.cpp @@ -4,27 +4,24 @@ //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #define BOOST_NO_EXCEPTIONS + #include -#include +#include -class my_exception: public std::exception { }; +class my_exception: public std::exception {}; -bool called=false; +int main() +{ + boost::throw_exception( my_exception() ); + return 1; +} -namespace -boost - { - void - throw_exception( std::exception const & ) - { - called=true; - } - } +namespace boost +{ -int -main() - { - boost::throw_exception(my_exception()); - BOOST_TEST(called); - return boost::report_errors(); - } +void throw_exception( std::exception const & ) +{ + std::exit( 0 ); +} + +} // namespace boost