From cce19ef60f3abadee9f6c2883ab11e6d6249cd50 Mon Sep 17 00:00:00 2001 From: Paul Groke Date: Wed, 15 Feb 2017 13:18:06 +0100 Subject: [PATCH 01/19] Don't include stuff inside #pragma warning push/pop, include boost/config.hpp before testing BOOST_ macros. --- include/boost/exception/exception.hpp | 15 +++++++++------ include/boost/throw_exception.hpp | 15 ++++++++------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index c0fdaf9..1787965 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -5,12 +5,8 @@ #ifndef UUID_274DA366004E11DCB1DDFE2E56D89593 #define UUID_274DA366004E11DCB1DDFE2E56D89593 -#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) -#pragma GCC system_header -#endif -#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) -#pragma warning(push,1) -#endif + +#include #ifdef BOOST_EXCEPTION_MINI_BOOST #include @@ -20,6 +16,13 @@ namespace boost { template class shared_ptr; }; namespace boost { namespace exception_detail { using boost::shared_ptr; } } #endif +#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma GCC system_header +#endif +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(push,1) +#endif + namespace boost { diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index aa977df..74ab0fb 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -1,11 +1,5 @@ #ifndef UUID_AA15E74A856F11E08B8D93F24824019B #define UUID_AA15E74A856F11E08B8D93F24824019B -#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) -#pragma GCC system_header -#endif -#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) -#pragma warning(push,1) -#endif // MS compatible compilers support #pragma once @@ -26,8 +20,8 @@ // http://www.boost.org/libs/utility/throw_exception.html // -#include #include +#include #include #if !defined( BOOST_EXCEPTION_DISABLE ) && defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x593) ) @@ -49,6 +43,13 @@ # define BOOST_THROW_EXCEPTION(x) ::boost::throw_exception(x) #endif +#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma GCC system_header +#endif +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(push,1) +#endif + namespace boost { #ifdef BOOST_NO_EXCEPTIONS From f5022b5ca8b820205cf3bbb800ebb02b3a115378 Mon Sep 17 00:00:00 2001 From: Peter Kolbus Date: Mon, 26 Mar 2018 22:38:33 -0500 Subject: [PATCH 02/19] Fix MSVC C4668 in throw_exception.hpp Fix MSVC C4668 warnings (undefined preprocessor macro) for __GNUC__ and __GNUC_MINOR__ by checking if __GNUC__ is defined first. --- include/boost/throw_exception.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index d45306c..c7d7637 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -3,7 +3,7 @@ #include -#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#if defined(__GNUC__) && (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) #pragma GCC system_header #endif #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) From f796dd892a5835aa577f91367f7879c3afe9ec2b Mon Sep 17 00:00:00 2001 From: Peter Kolbus Date: Mon, 26 Mar 2018 22:39:26 -0500 Subject: [PATCH 03/19] Fix MSVC C4668 in exception.hpp Fix MSVC C4668 warnings (undefined preprocessor macro) for __GNUC__ and __GNUC_MINOR__ by checking if __GNUC__ is defined first. --- include/boost/exception/exception.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index c0fdaf9..d24845f 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -5,7 +5,7 @@ #ifndef UUID_274DA366004E11DCB1DDFE2E56D89593 #define UUID_274DA366004E11DCB1DDFE2E56D89593 -#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#if defined(__GNUC__) && (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) #pragma GCC system_header #endif #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) From 10f3663798efe5ecef308eddb5e83969477bc483 Mon Sep 17 00:00:00 2001 From: Mike Dev Date: Tue, 18 Sep 2018 13:19:19 +0200 Subject: [PATCH 04/19] [CMake] Generate cmake target that other libraries can use ... to express their dependency on this library and retrieve any configuration information such as the include directory, binary to link to (if any), transitive dependencies, necessary compiler options or the required c++ standards level. --- CMakeLists.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..ce413e0 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright 2018 Mike Dev +# 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 + +cmake_minimum_required(VERSION 3.5) +project(BoostThrowException LANGUAGES CXX) + +add_library(boost_throw_exception INTERFACE) +add_library(Boost::throw_exception ALIAS boost_throw_exception) + +target_include_directories(boost_throw_exception INTERFACE include) + +target_link_libraries(boost_static_assert + INTERFACE + Boost::assert + Boost::config +) From aec4ca6914612c6b6ead9359801aa3bd4865f2e3 Mon Sep 17 00:00:00 2001 From: Mike Dev Date: Thu, 20 Sep 2018 12:57:12 +0200 Subject: [PATCH 05/19] [CMake] Fix library name --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ce413e0..8b57472 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ add_library(Boost::throw_exception ALIAS boost_throw_exception) target_include_directories(boost_throw_exception INTERFACE include) -target_link_libraries(boost_static_assert +target_link_libraries(boost_throw_exception INTERFACE Boost::assert Boost::config From 8b879067f7da2c286617c4994ea2e7b141df568e Mon Sep 17 00:00:00 2001 From: van Bergen Emile Date: Tue, 25 Sep 2018 10:40:26 +0200 Subject: [PATCH 06/19] Replaced hardcoded symbol visibility for GCC with BOOST_SYMBOL_VISIBLE --- include/boost/exception/exception.hpp | 55 +++------------------------ 1 file changed, 5 insertions(+), 50 deletions(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index c0fdaf9..f0ba665 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -140,17 +140,8 @@ boost } }; -#if defined(__GNUC__) -# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) -# pragma GCC visibility push (default) -# endif -#endif + BOOST_SYMBOL_VISIBLE class exception; -#if defined(__GNUC__) -# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) -# pragma GCC visibility pop -# endif -#endif namespace exception_detail @@ -216,11 +207,7 @@ boost E const & set_info( E const &, throw_line const & ); } -#if defined(__GNUC__) -# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) -# pragma GCC visibility push (default) -# endif -#endif + BOOST_SYMBOL_VISIBLE class exception { @@ -293,11 +280,6 @@ boost mutable char const * throw_file_; mutable int throw_line_; }; -#if defined(__GNUC__) -# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) -# pragma GCC visibility pop -# endif -#endif inline exception:: @@ -338,12 +320,8 @@ boost namespace exception_detail { -#if defined(__GNUC__) -# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) -# pragma GCC visibility push (default) -# endif -#endif template + BOOST_SYMBOL_VISIBLE struct error_info_injector: public T, @@ -359,11 +337,6 @@ boost { } }; -#if defined(__GNUC__) -# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) -# pragma GCC visibility pop -# endif -#endif struct large_size { char c[256]; }; large_size dispatch_boost_exception( exception const * ); @@ -411,11 +384,7 @@ boost namespace exception_detail { -#if defined(__GNUC__) -# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) -# pragma GCC visibility push (default) -# endif -#endif + BOOST_SYMBOL_VISIBLE class clone_base { @@ -429,11 +398,6 @@ boost { } }; -#if defined(__GNUC__) -# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) -# pragma GCC visibility pop -# endif -#endif inline void @@ -454,12 +418,8 @@ boost { } -#if defined(__GNUC__) -# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) -# pragma GCC visibility push (default) -# endif -#endif template + BOOST_SYMBOL_VISIBLE class clone_impl: public T, @@ -500,11 +460,6 @@ boost } }; } -#if defined(__GNUC__) -# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) -# pragma GCC visibility pop -# endif -#endif template inline From e3b556a978b786963eb9a7a9cf22e8ccc38b5903 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 25 Sep 2018 16:00:51 +0300 Subject: [PATCH 07/19] Add .travis.yml --- .travis.yml | 281 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 281 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..f0387fc --- /dev/null +++ b/.travis.yml @@ -0,0 +1,281 @@ +# Copyright 2016-2018 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) + +language: cpp + +sudo: false + +python: "2.7" + +branches: + only: + - master + - develop + - /feature\/.*/ + +env: + matrix: + - BOGUS_JOB=true + +matrix: + + exclude: + - env: BOGUS_JOB=true + + include: + - os: linux + compiler: g++ + env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11 + + - os: linux + compiler: g++-4.4 + env: TOOLSET=gcc COMPILER=g++-4.4 CXXSTD=98,0x + addons: + apt: + packages: + - g++-4.4 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: g++-4.6 + env: TOOLSET=gcc COMPILER=g++-4.6 CXXSTD=03,0x + addons: + apt: + packages: + - g++-4.6 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: g++-4.7 + env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11 + addons: + apt: + packages: + - g++-4.7 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: g++-4.8 + env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11 + addons: + apt: + packages: + - g++-4.8 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: g++-4.9 + env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11 + addons: + apt: + packages: + - g++-4.9 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: g++-5 + env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z + addons: + apt: + packages: + - g++-5 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: g++-6 + env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z + addons: + apt: + packages: + - g++-6 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: g++-7 + env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17 + addons: + apt: + packages: + - g++-7 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: g++-8 + env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17 + addons: + apt: + packages: + - g++-8 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: g++-8 + env: UBSAN=1 TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17 UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold + addons: + apt: + packages: + - g++-8 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: clang++ + env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11 + + - os: linux + compiler: /usr/bin/clang++ + env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11 + addons: + apt: + packages: + - clang-3.3 + + - os: linux + compiler: /usr/bin/clang++ + env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11 + addons: + apt: + packages: + - clang-3.4 + + - os: linux + compiler: clang++-3.5 + env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11,14,1z + addons: + apt: + packages: + - clang-3.5 + - libstdc++-4.9-dev + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: clang++-3.6 + env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03,11,14,1z + addons: + apt: + packages: + - clang-3.6 + - libstdc++-4.9-dev + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: clang++-3.8 + env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03,11,14,1z + addons: + apt: + packages: + - clang-3.8 + - libstdc++-4.9-dev + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: clang++-3.9 + env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03,11,14,1z + addons: + apt: + packages: + - clang-3.9 + - libstdc++-4.9-dev + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: clang++-4.0 + env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03,11,14,1z + addons: + apt: + packages: + - clang-4.0 + - libstdc++-4.9-dev + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-trusty-4.0 + + - os: linux + compiler: clang++-5.0 + env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z + addons: + apt: + packages: + - clang-5.0 + - libstdc++-4.9-dev + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-trusty-5.0 + + - os: linux + compiler: clang++-6.0 + env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17 + addons: + apt: + packages: + - clang-6.0 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-trusty-6.0 + + - os: linux + compiler: clang++-6.0 + env: UBSAN=1 TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17 UBSAN_OPTIONS=print_stacktrace=1 + addons: + apt: + packages: + - clang-6.0 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-trusty-6.0 + + - os: linux + compiler: clang++-libc++ + env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z + addons: + apt: + packages: + - libc++-dev + + - os: linux + compiler: clang++-libc++ + env: UBSAN=1 TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1 + addons: + apt: + packages: + - libc++-dev + + - os: osx + compiler: clang++ + env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z + +install: + - BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true + - cd .. + - git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root + - cd boost-root + - git submodule update --init tools/build + - git submodule update --init libs/config + - git submodule update --init tools/boostdep + - cp -r $TRAVIS_BUILD_DIR/* libs/throw_exception + - python tools/boostdep/depinst/depinst.py throw_exception + - ./bootstrap.sh + - ./b2 headers + +script: + - |- + echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam + - ./b2 -j 3 libs/throw_exception/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined define=UBSAN=1 debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS} + +notifications: + email: + on_success: always From ee45839a7851de13ae12c6a68bcbf9ae3d7b2356 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 25 Sep 2018 20:18:43 +0300 Subject: [PATCH 08/19] Add appveyor.yml --- appveyor.yml | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..3882c91 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,73 @@ +# Copyright 2016-2018 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) + +version: 1.0.{build}-{branch} + +shallow_clone: true + +branches: + only: + - master + - develop + - /feature\/.*/ + +environment: + matrix: + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + TOOLSET: msvc-9.0 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + TOOLSET: msvc-10.0 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + TOOLSET: msvc-11.0 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + TOOLSET: msvc-12.0 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + TOOLSET: msvc-14.0 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + TOOLSET: msvc-14.1 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + TOOLSET: msvc-14.1 + CXXSTD: 17 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + ADDPATH: C:\cygwin\bin; + TOOLSET: gcc + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + ADDPATH: C:\cygwin\bin; + TOOLSET: gcc + CXXSTD: 03,11 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + ADDPATH: C:\mingw\bin; + TOOLSET: gcc + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + ADDPATH: C:\mingw\bin; + TOOLSET: gcc + CXXSTD: 03,11 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin; + TOOLSET: gcc + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin; + TOOLSET: gcc + CXXSTD: 03,11 + +install: + - set BOOST_BRANCH=develop + - if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master + - cd .. + - git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root + - cd boost-root + - git submodule update --init tools/build + - git submodule update --init libs/config + - git submodule update --init tools/boostdep + - xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\throw_exception + - python tools/boostdep/depinst/depinst.py throw_exception + - cmd /c bootstrap + - b2 headers + +build: off + +test_script: + - PATH=%ADDPATH%%PATH% + - if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD% + - b2 -j 3 libs/throw_exception/test toolset=%TOOLSET% %CXXSTD% From 614cbc4f34f4d85c2cfe985b989844353d08f613 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 25 Sep 2018 20:55:04 +0300 Subject: [PATCH 09/19] Add throw_from_library_test --- test/Jamfile.v2 | 13 ++++++------ test/lib1_throw.cpp | 13 ++++++++++++ test/lib1_throw.hpp | 35 ++++++++++++++++++++++++++++++++ test/lib2_throw.cpp | 14 +++++++++++++ test/lib2_throw.hpp | 35 ++++++++++++++++++++++++++++++++ test/lib3_throw.cpp | 14 +++++++++++++ test/lib3_throw.hpp | 35 ++++++++++++++++++++++++++++++++ test/throw_from_library_test.cpp | 20 ++++++++++++++++++ 8 files changed, 173 insertions(+), 6 deletions(-) create mode 100644 test/lib1_throw.cpp create mode 100644 test/lib1_throw.hpp create mode 100644 test/lib2_throw.cpp create mode 100644 test/lib2_throw.hpp create mode 100644 test/lib3_throw.cpp create mode 100644 test/lib3_throw.hpp create mode 100644 test/throw_from_library_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 39782fd..28f75df 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -7,15 +7,16 @@ import testing ; -project - : requirements - static - on - ; - run throw_exception_test.cpp ; run throw_exception_no_exceptions_test.cpp ; run throw_exception_no_integration_test.cpp ; run throw_exception_no_both_test.cpp ; compile-fail throw_exception_fail.cpp ; + +lib lib1_throw : lib1_throw.cpp : LIB1_SOURCE=1 shared:LIB1_DYN_LINK=1 : : shared:LIB1_DYN_LINK=1 ; +lib lib2_throw : lib2_throw.cpp : LIB2_SOURCE=1 shared:LIB2_DYN_LINK=1 : : shared:LIB2_DYN_LINK=1 ; +lib lib3_throw : lib3_throw.cpp : LIB3_SOURCE=1 shared:LIB3_DYN_LINK=1 : : shared:LIB3_DYN_LINK=1 ; + +run throw_from_library_test.cpp lib1_throw lib2_throw lib3_throw : : : static : throw_from_library_static ; +run throw_from_library_test.cpp lib1_throw lib2_throw lib3_throw : : : shared : throw_from_library_shared ; diff --git a/test/lib1_throw.cpp b/test/lib1_throw.cpp new file mode 100644 index 0000000..4dadd17 --- /dev/null +++ b/test/lib1_throw.cpp @@ -0,0 +1,13 @@ +// Copyright 2018 Peter Dimov +// +// 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 "lib1_throw.hpp" + +void lib1::f() +{ + throw lib1::exception(); +} diff --git a/test/lib1_throw.hpp b/test/lib1_throw.hpp new file mode 100644 index 0000000..4f960bf --- /dev/null +++ b/test/lib1_throw.hpp @@ -0,0 +1,35 @@ +#ifndef LIB1_THROW_HPP_INCLUDED +#define LIB1_THROW_HPP_INCLUDED + +// Copyright 2018 Peter Dimov +// +// 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 +#include + +#if defined(LIB1_DYN_LINK) +# if defined(LIB1_SOURCE) +# define LIB1_DECL BOOST_SYMBOL_EXPORT +# else +# define LIB1_DECL BOOST_SYMBOL_IMPORT +# endif +#else +# define LIB1_DECL +#endif + +namespace lib1 +{ + +struct exception: public std::exception +{ +}; + +LIB1_DECL void f(); + +} // namespace lib1 + +#endif // #ifndef LIB1_THROW_HPP_INCLUDED diff --git a/test/lib2_throw.cpp b/test/lib2_throw.cpp new file mode 100644 index 0000000..fc1e442 --- /dev/null +++ b/test/lib2_throw.cpp @@ -0,0 +1,14 @@ +// Copyright 2018 Peter Dimov +// +// 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 "lib2_throw.hpp" +#include + +void lib2::f() +{ + boost::throw_exception( lib2::exception() ); +} diff --git a/test/lib2_throw.hpp b/test/lib2_throw.hpp new file mode 100644 index 0000000..9e85dea --- /dev/null +++ b/test/lib2_throw.hpp @@ -0,0 +1,35 @@ +#ifndef LIB2_THROW_HPP_INCLUDED +#define LIB2_THROW_HPP_INCLUDED + +// Copyright 2018 Peter Dimov +// +// 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 +#include + +#if defined(LIB2_DYN_LINK) +# if defined(LIB2_SOURCE) +# define LIB2_DECL BOOST_SYMBOL_EXPORT +# else +# define LIB2_DECL BOOST_SYMBOL_IMPORT +# endif +#else +# define LIB2_DECL +#endif + +namespace lib2 +{ + +struct exception: public std::exception +{ +}; + +LIB2_DECL void f(); + +} // namespace lib2 + +#endif // #ifndef LIB2_THROW_HPP_INCLUDED diff --git a/test/lib3_throw.cpp b/test/lib3_throw.cpp new file mode 100644 index 0000000..eb7d348 --- /dev/null +++ b/test/lib3_throw.cpp @@ -0,0 +1,14 @@ +// Copyright 2018 Peter Dimov +// +// 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 "lib3_throw.hpp" +#include + +void lib3::f() +{ + BOOST_THROW_EXCEPTION( lib3::exception() ); +} diff --git a/test/lib3_throw.hpp b/test/lib3_throw.hpp new file mode 100644 index 0000000..5144b30 --- /dev/null +++ b/test/lib3_throw.hpp @@ -0,0 +1,35 @@ +#ifndef LIB3_THROW_HPP_INCLUDED +#define LIB3_THROW_HPP_INCLUDED + +// Copyright 2018 Peter Dimov +// +// 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 +#include + +#if defined(LIB3_DYN_LINK) +# if defined(LIB3_SOURCE) +# define LIB3_DECL BOOST_SYMBOL_EXPORT +# else +# define LIB3_DECL BOOST_SYMBOL_IMPORT +# endif +#else +# define LIB3_DECL +#endif + +namespace lib3 +{ + +struct exception: public std::exception +{ +}; + +LIB3_DECL void f(); + +} // namespace lib3 + +#endif // #ifndef LIB3_THROW_HPP_INCLUDED diff --git a/test/throw_from_library_test.cpp b/test/throw_from_library_test.cpp new file mode 100644 index 0000000..154c3a6 --- /dev/null +++ b/test/throw_from_library_test.cpp @@ -0,0 +1,20 @@ +// Copyright 2018 Peter Dimov +// +// 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 "lib1_throw.hpp" +#include "lib2_throw.hpp" +#include "lib3_throw.hpp" +#include + +int main() +{ + BOOST_TEST_THROWS( lib1::f(), lib1::exception ); + BOOST_TEST_THROWS( lib2::f(), lib2::exception ); + BOOST_TEST_THROWS( lib3::f(), lib3::exception ); + + return boost::report_errors(); +} From 3fba666bea6a692412792efeade1ad2853f8bcd0 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 25 Sep 2018 21:28:01 +0300 Subject: [PATCH 10/19] Update appveyor.yml --- appveyor.yml | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 3882c91..7c73191 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -15,41 +15,28 @@ branches: environment: matrix: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - TOOLSET: msvc-9.0 - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - TOOLSET: msvc-10.0 - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - TOOLSET: msvc-11.0 - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - TOOLSET: msvc-12.0 + TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 TOOLSET: msvc-14.0 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 TOOLSET: msvc-14.1 - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - TOOLSET: msvc-14.1 - CXXSTD: 17 + CXXSTD: 14,17 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 ADDPATH: C:\cygwin\bin; TOOLSET: gcc + CXXSTD: 03,11,14,1z - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - ADDPATH: C:\cygwin\bin; + ADDPATH: C:\cygwin64\bin; TOOLSET: gcc - CXXSTD: 03,11 + CXXSTD: 03,11,14,1z - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 ADDPATH: C:\mingw\bin; TOOLSET: gcc - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - ADDPATH: C:\mingw\bin; - TOOLSET: gcc - CXXSTD: 03,11 + CXXSTD: 03,11,14,1z - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin; TOOLSET: gcc - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin; - TOOLSET: gcc - CXXSTD: 03,11 + CXXSTD: 03,11,14,1z install: - set BOOST_BRANCH=develop From ca4697690825b750067877bf953d1c65e71cb8e4 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 25 Sep 2018 21:32:23 +0300 Subject: [PATCH 11/19] Add -d0 to b2 headers on Appveyor --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 7c73191..15fb16c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -50,7 +50,7 @@ install: - xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\throw_exception - python tools/boostdep/depinst/depinst.py throw_exception - cmd /c bootstrap - - b2 headers + - b2 -d0 headers build: off From 9d4394681294d003f77b9175c6897f7c96af7f13 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 26 Sep 2018 03:48:09 +0300 Subject: [PATCH 12/19] Add BOOST_SYMBOL_VISIBLE to exception types in throw_from_library_test --- test/lib1_throw.hpp | 2 +- test/lib2_throw.hpp | 2 +- test/lib3_throw.hpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/lib1_throw.hpp b/test/lib1_throw.hpp index 4f960bf..f3d169b 100644 --- a/test/lib1_throw.hpp +++ b/test/lib1_throw.hpp @@ -24,7 +24,7 @@ namespace lib1 { -struct exception: public std::exception +struct BOOST_SYMBOL_VISIBLE exception: public std::exception { }; diff --git a/test/lib2_throw.hpp b/test/lib2_throw.hpp index 9e85dea..59e8dc2 100644 --- a/test/lib2_throw.hpp +++ b/test/lib2_throw.hpp @@ -24,7 +24,7 @@ namespace lib2 { -struct exception: public std::exception +struct BOOST_SYMBOL_VISIBLE exception: public std::exception { }; diff --git a/test/lib3_throw.hpp b/test/lib3_throw.hpp index 5144b30..da280ab 100644 --- a/test/lib3_throw.hpp +++ b/test/lib3_throw.hpp @@ -24,7 +24,7 @@ namespace lib3 { -struct exception: public std::exception +struct BOOST_SYMBOL_VISIBLE exception: public std::exception { }; From 7e2f1b4ecdb8d0de51cd9f4c60f47077e14d83ed Mon Sep 17 00:00:00 2001 From: Nikita Kniazev Date: Wed, 26 Sep 2018 15:28:19 +0300 Subject: [PATCH 13/19] Removed extra semicolon --- include/boost/exception/exception.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index 1787965..650c857 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -12,7 +12,7 @@ #include namespace boost { namespace exception_detail { using std::shared_ptr; } } #else -namespace boost { template class shared_ptr; }; +namespace boost { template class shared_ptr; } namespace boost { namespace exception_detail { using boost::shared_ptr; } } #endif From fe0f62bf1726cbc503ac664c24ac187bff789aae Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 27 Sep 2018 00:53:52 +0300 Subject: [PATCH 14/19] Move BOOST_SYMBOL_VISIBLE after class --- include/boost/exception/exception.hpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index 8eda706..1aa6718 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -143,8 +143,9 @@ boost } }; + class BOOST_SYMBOL_VISIBLE - class exception; + exception; namespace exception_detail @@ -210,8 +211,8 @@ boost E const & set_info( E const &, throw_line const & ); } - BOOST_SYMBOL_VISIBLE class + BOOST_SYMBOL_VISIBLE exception { // @@ -324,8 +325,8 @@ boost exception_detail { template - BOOST_SYMBOL_VISIBLE struct + BOOST_SYMBOL_VISIBLE error_info_injector: public T, public exception @@ -387,8 +388,8 @@ boost namespace exception_detail { - BOOST_SYMBOL_VISIBLE class + BOOST_SYMBOL_VISIBLE clone_base { public: @@ -422,8 +423,8 @@ boost } template - BOOST_SYMBOL_VISIBLE class + BOOST_SYMBOL_VISIBLE clone_impl: public T, public virtual clone_base From a17f4bad42ba524ee4b3a08960029df04c077133 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 27 Sep 2018 07:10:41 +0300 Subject: [PATCH 15/19] Add test that catches by boost::exception --- test/Jamfile.v2 | 2 ++ test/throw_exception_test2.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 test/throw_exception_test2.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 28f75df..bfb1aa4 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -14,6 +14,8 @@ run throw_exception_no_both_test.cpp ; compile-fail throw_exception_fail.cpp ; +run throw_exception_test2.cpp ; + lib lib1_throw : lib1_throw.cpp : LIB1_SOURCE=1 shared:LIB1_DYN_LINK=1 : : shared:LIB1_DYN_LINK=1 ; lib lib2_throw : lib2_throw.cpp : LIB2_SOURCE=1 shared:LIB2_DYN_LINK=1 : : shared:LIB2_DYN_LINK=1 ; lib lib3_throw : lib3_throw.cpp : LIB3_SOURCE=1 shared:LIB3_DYN_LINK=1 : : shared:LIB3_DYN_LINK=1 ; diff --git a/test/throw_exception_test2.cpp b/test/throw_exception_test2.cpp new file mode 100644 index 0000000..c9d35de --- /dev/null +++ b/test/throw_exception_test2.cpp @@ -0,0 +1,28 @@ +// Copyright 2018 Peter Dimov +// +// 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 +#include + +class my_exception: public std::exception +{ +}; + +class my_exception2: public std::exception, public boost::exception +{ +}; + +int main() +{ + BOOST_TEST_THROWS( boost::throw_exception( my_exception() ), boost::exception ); + BOOST_TEST_THROWS( boost::throw_exception( my_exception2() ), boost::exception ); + + BOOST_TEST_THROWS( BOOST_THROW_EXCEPTION( my_exception() ), boost::exception ); + BOOST_TEST_THROWS( BOOST_THROW_EXCEPTION( my_exception2() ), boost::exception ); + + return boost::report_errors(); +} From 6845ba892dc1ff3f949aecd8479feae2bb0ced08 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 27 Sep 2018 07:15:53 +0300 Subject: [PATCH 16/19] Add test that uses boost::exception_ptr --- test/Jamfile.v2 | 1 + test/throw_exception_test3.cpp | 71 ++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 test/throw_exception_test3.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index bfb1aa4..f635925 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -15,6 +15,7 @@ run throw_exception_no_both_test.cpp ; compile-fail throw_exception_fail.cpp ; run throw_exception_test2.cpp ; +run throw_exception_test3.cpp ; lib lib1_throw : lib1_throw.cpp : LIB1_SOURCE=1 shared:LIB1_DYN_LINK=1 : : shared:LIB1_DYN_LINK=1 ; lib lib2_throw : lib2_throw.cpp : LIB2_SOURCE=1 shared:LIB2_DYN_LINK=1 : : shared:LIB2_DYN_LINK=1 ; diff --git a/test/throw_exception_test3.cpp b/test/throw_exception_test3.cpp new file mode 100644 index 0000000..7f20420 --- /dev/null +++ b/test/throw_exception_test3.cpp @@ -0,0 +1,71 @@ +// Copyright 2018 Peter Dimov +// +// 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 +#include +#include + +class my_exception: public std::exception +{ +}; + +class my_exception2: public std::exception, public boost::exception +{ +}; + +int main() +{ + try + { + boost::throw_exception( my_exception() ); + } + catch( ... ) + { + boost::exception_ptr p = boost::current_exception(); + + BOOST_TEST_THROWS( boost::rethrow_exception( p ), my_exception ); + BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception ); + } + + try + { + boost::throw_exception( my_exception2() ); + } + catch( ... ) + { + boost::exception_ptr p = boost::current_exception(); + + BOOST_TEST_THROWS( boost::rethrow_exception( p ), my_exception2 ); + BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception ); + } + + try + { + BOOST_THROW_EXCEPTION( my_exception() ); + } + catch( ... ) + { + boost::exception_ptr p = boost::current_exception(); + + BOOST_TEST_THROWS( boost::rethrow_exception( p ), my_exception ); + BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception ); + } + + try + { + BOOST_THROW_EXCEPTION( my_exception2() ); + } + catch( ... ) + { + boost::exception_ptr p = boost::current_exception(); + + BOOST_TEST_THROWS( boost::rethrow_exception( p ), my_exception2 ); + BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception ); + } + + return boost::report_errors(); +} From a732dfad3c960e85ce8bf855cc887b77ed8c4cca Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 27 Sep 2018 07:23:52 +0300 Subject: [PATCH 17/19] Add boost::exception, exception_ptr tests to throw_from_library_test as well --- test/throw_from_library_test.cpp | 44 +++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/test/throw_from_library_test.cpp b/test/throw_from_library_test.cpp index 154c3a6..3adfa0c 100644 --- a/test/throw_from_library_test.cpp +++ b/test/throw_from_library_test.cpp @@ -8,13 +8,55 @@ #include "lib1_throw.hpp" #include "lib2_throw.hpp" #include "lib3_throw.hpp" +#include +#include #include -int main() +void test_catch_by_type() { BOOST_TEST_THROWS( lib1::f(), lib1::exception ); BOOST_TEST_THROWS( lib2::f(), lib2::exception ); BOOST_TEST_THROWS( lib3::f(), lib3::exception ); +} + +void test_catch_by_exception() +{ + BOOST_TEST_THROWS( lib2::f(), boost::exception ); + BOOST_TEST_THROWS( lib3::f(), boost::exception ); +} + +void test_exception_ptr() +{ + try + { + lib2::f(); + } + catch( ... ) + { + boost::exception_ptr p = boost::current_exception(); + + BOOST_TEST_THROWS( boost::rethrow_exception( p ), lib2::exception ); + BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception ); + } + + try + { + lib3::f(); + } + catch( ... ) + { + boost::exception_ptr p = boost::current_exception(); + + BOOST_TEST_THROWS( boost::rethrow_exception( p ), lib3::exception ); + BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception ); + } +} + +int main() +{ + test_catch_by_type(); + test_catch_by_exception(); + test_exception_ptr(); return boost::report_errors(); } From 9b99dd5f60bfa33c3ba232d207c41db34d2d1583 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 27 Sep 2018 08:26:29 +0300 Subject: [PATCH 18/19] Add tests for throw_line --- test/Jamfile.v2 | 1 + test/throw_exception_test4.cpp | 47 ++++++++++++++++++++++++++++++++ test/throw_from_library_test.cpp | 17 ++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 test/throw_exception_test4.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index f635925..e28308d 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -16,6 +16,7 @@ compile-fail throw_exception_fail.cpp ; run throw_exception_test2.cpp ; run throw_exception_test3.cpp ; +run throw_exception_test4.cpp ; lib lib1_throw : lib1_throw.cpp : LIB1_SOURCE=1 shared:LIB1_DYN_LINK=1 : : shared:LIB1_DYN_LINK=1 ; lib lib2_throw : lib2_throw.cpp : LIB2_SOURCE=1 shared:LIB2_DYN_LINK=1 : : shared:LIB2_DYN_LINK=1 ; diff --git a/test/throw_exception_test4.cpp b/test/throw_exception_test4.cpp new file mode 100644 index 0000000..5b8e303 --- /dev/null +++ b/test/throw_exception_test4.cpp @@ -0,0 +1,47 @@ +// Copyright 2018 Peter Dimov +// +// 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 +#include +#include + +class my_exception: public std::exception +{ +}; + +class my_exception2: public std::exception, public boost::exception +{ +}; + +int main() +{ + try + { + BOOST_THROW_EXCEPTION( my_exception() ); + } + catch( boost::exception const & x ) + { + int const * line = boost::get_error_info( x ); + + BOOST_TEST( line != 0 ); + BOOST_TEST_EQ( *line, 24 ); + } + + try + { + BOOST_THROW_EXCEPTION( my_exception2() ); + } + catch( boost::exception const & x ) + { + int const * line = boost::get_error_info( x ); + + BOOST_TEST( line != 0 ); + BOOST_TEST_EQ( *line, 36 ); + } + + return boost::report_errors(); +} diff --git a/test/throw_from_library_test.cpp b/test/throw_from_library_test.cpp index 3adfa0c..22a89da 100644 --- a/test/throw_from_library_test.cpp +++ b/test/throw_from_library_test.cpp @@ -10,6 +10,7 @@ #include "lib3_throw.hpp" #include #include +#include #include void test_catch_by_type() @@ -52,11 +53,27 @@ void test_exception_ptr() } } +void test_throw_line() +{ + try + { + lib3::f(); + } + catch( boost::exception const & x ) + { + int const * line = boost::get_error_info( x ); + + BOOST_TEST( line != 0 ); + BOOST_TEST_EQ( *line, 13 ); + } +} + int main() { test_catch_by_type(); test_catch_by_exception(); test_exception_ptr(); + test_throw_line(); return boost::report_errors(); } From eafb1c877be7bc6713e31f035f96b8ba009d9fcf Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 30 Sep 2018 04:05:09 +0300 Subject: [PATCH 19/19] Add 'unsupported' comment to CMakeLists.txt --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b57472..c44ceba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,9 @@ # 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 +# Partial (add_subdirectory only) and experimental CMake support +# Subject to change; please do not rely on the contents of this file yet + cmake_minimum_required(VERSION 3.5) project(BoostThrowException LANGUAGES CXX)