forked from boostorg/throw_exception
Compare commits
28 Commits
boost-1.76
...
feature/wr
Author | SHA1 | Date | |
---|---|---|---|
0287751675 | |||
0bfe1d9261 | |||
6624c33710 | |||
7d804d72b8 | |||
f1419ae6de | |||
bba0872af3 | |||
e13250de6e | |||
9304126070 | |||
cbff90bdee | |||
5dc7cafd9f | |||
e1fd6bb1f8 | |||
8c7b14f68b | |||
37ad7254d2 | |||
f6055628e6 | |||
65eddbb2f0 | |||
121c1407fd | |||
5eff93e41b | |||
8787d13e65 | |||
0a922307ec | |||
9ca27bddfc | |||
1d555aff4b | |||
b432f24664 | |||
9f6a2e7b89 | |||
95e02ea52b | |||
834a4f04dc | |||
ad30f163ef | |||
b1f6a8b25f | |||
264ee74b64 |
71
.github/workflows/ci.yml
vendored
71
.github/workflows/ci.yml
vendored
@ -17,24 +17,17 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- toolset: gcc-4.7
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-16.04
|
||||
install: g++-4.7
|
||||
- toolset: gcc-4.8
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-16.04
|
||||
os: ubuntu-18.04
|
||||
install: g++-4.8
|
||||
- toolset: gcc-4.9
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-16.04
|
||||
install: g++-4.9
|
||||
- toolset: gcc-5
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-16.04
|
||||
os: ubuntu-18.04
|
||||
install: g++-5
|
||||
- toolset: gcc-6
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-16.04
|
||||
os: ubuntu-18.04
|
||||
install: g++-6
|
||||
- toolset: gcc-7
|
||||
cxxstd: "03,11,14,17"
|
||||
@ -42,51 +35,38 @@ jobs:
|
||||
- toolset: gcc-8
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
install: g++-8
|
||||
- toolset: gcc-9
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-20.04
|
||||
- toolset: gcc-10
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
- toolset: clang
|
||||
compiler: clang++-3.5
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-16.04
|
||||
install: clang-3.5
|
||||
- toolset: clang
|
||||
compiler: clang++-3.6
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-16.04
|
||||
install: clang-3.6
|
||||
- toolset: clang
|
||||
compiler: clang++-3.7
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-16.04
|
||||
install: clang-3.7
|
||||
- toolset: clang
|
||||
compiler: clang++-3.8
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-16.04
|
||||
install: clang-3.8
|
||||
os: ubuntu-20.04
|
||||
install: g++-10
|
||||
- toolset: gcc-11
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: g++-11
|
||||
- toolset: clang
|
||||
compiler: clang++-3.9
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-16.04
|
||||
os: ubuntu-18.04
|
||||
install: clang-3.9
|
||||
- toolset: clang
|
||||
compiler: clang++-4.0
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-16.04
|
||||
os: ubuntu-18.04
|
||||
install: clang-4.0
|
||||
- toolset: clang
|
||||
compiler: clang++-5.0
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-16.04
|
||||
os: ubuntu-18.04
|
||||
install: clang-5.0
|
||||
- toolset: clang
|
||||
compiler: clang++-6.0
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-18.04
|
||||
install: clang-6.0
|
||||
- toolset: clang
|
||||
compiler: clang++-7
|
||||
cxxstd: "03,11,14,17"
|
||||
@ -94,16 +74,29 @@ jobs:
|
||||
install: clang-7
|
||||
- toolset: clang
|
||||
compiler: clang++-8
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-20.04
|
||||
install: clang-8
|
||||
- toolset: clang
|
||||
compiler: clang++-9
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: clang-9
|
||||
- toolset: clang
|
||||
compiler: clang++-10
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: clang-10
|
||||
- toolset: clang
|
||||
compiler: clang++-11
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: clang-11
|
||||
- toolset: clang
|
||||
compiler: clang++-12
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: clang-12
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: macos-10.15
|
||||
@ -162,6 +155,10 @@ jobs:
|
||||
cxxstd: "14,17,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2019
|
||||
- toolset: msvc-14.3
|
||||
cxxstd: "14,17,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2022
|
||||
- toolset: gcc
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
addrmd: 64
|
||||
|
74
.travis.yml
74
.travis.yml
@ -22,10 +22,6 @@ matrix:
|
||||
- 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
|
||||
@ -127,19 +123,16 @@ matrix:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-9
|
||||
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-9 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
|
||||
dist: bionic
|
||||
compiler: g++-10
|
||||
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-10 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-9
|
||||
- g++-10
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: /usr/bin/clang++
|
||||
@ -220,6 +213,7 @@ matrix:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-5.0
|
||||
env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
@ -230,6 +224,7 @@ matrix:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-6.0
|
||||
env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17
|
||||
addons:
|
||||
@ -240,6 +235,7 @@ matrix:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-7
|
||||
env: TOOLSET=clang COMPILER=clang++-7 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
@ -248,9 +244,10 @@ matrix:
|
||||
- clang-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-xenial-7
|
||||
- llvm-toolchain-bionic-7
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-8
|
||||
env: TOOLSET=clang COMPILER=clang++-8 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
@ -259,9 +256,10 @@ matrix:
|
||||
- clang-8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-xenial-8
|
||||
- llvm-toolchain-bionic-8
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-9
|
||||
env: TOOLSET=clang COMPILER=clang++-9 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
@ -270,28 +268,47 @@ matrix:
|
||||
- clang-9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main'
|
||||
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-8
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-8 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
|
||||
dist: bionic
|
||||
compiler: clang++-10
|
||||
env: TOOLSET=clang COMPILER=clang++-10 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-8
|
||||
- clang-10
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-xenial-8
|
||||
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: clang++-libc++
|
||||
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
|
||||
dist: bionic
|
||||
compiler: clang++-11
|
||||
env: TOOLSET=clang COMPILER=clang++-11 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libc++-dev
|
||||
- clang-11
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-12
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-12 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-12
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-12 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
@ -302,9 +319,14 @@ matrix:
|
||||
packages:
|
||||
- libc++-dev
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-libc++
|
||||
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libc++-dev
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
@ -314,7 +336,7 @@ matrix:
|
||||
env: CMAKE=1
|
||||
script:
|
||||
- mkdir __build__ && cd __build__
|
||||
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES=throw_exception ..
|
||||
- cmake -DBOOST_ENABLE_CMAKE=1 -DBUILD_TESTING=ON -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES=throw_exception ..
|
||||
- ctest --output-on-failure -R boost_throw_exception
|
||||
|
||||
- os: linux
|
||||
|
@ -9,6 +9,8 @@ Peter Dimov, Emil Dotchevski
|
||||
:toc: left
|
||||
:idprefix:
|
||||
:docinfo: private-footer
|
||||
:source-highlighter: rouge
|
||||
:source-language: c++
|
||||
|
||||
:leveloffset: +1
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#define BOOST_EXCEPTION_274DA366004E11DCB1DDFE2E56D89593
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <exception>
|
||||
|
||||
#ifdef BOOST_EXCEPTION_MINI_BOOST
|
||||
#include <memory>
|
||||
@ -390,6 +391,9 @@ boost
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
#if defined(BOOST_NO_EXCEPTIONS)
|
||||
BOOST_NORETURN void throw_exception(std::exception const & e); // user defined
|
||||
#endif
|
||||
|
||||
namespace
|
||||
exception_detail
|
||||
@ -466,7 +470,11 @@ boost
|
||||
void
|
||||
rethrow() const
|
||||
{
|
||||
#if defined(BOOST_NO_EXCEPTIONS)
|
||||
boost::throw_exception(*this);
|
||||
#else
|
||||
throw*this;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <exception>
|
||||
#include <cstddef>
|
||||
|
||||
#if !defined( BOOST_EXCEPTION_DISABLE ) && defined( BOOST_BORLANDC ) && BOOST_WORKAROUND( BOOST_BORLANDC, BOOST_TESTED_AT(0x593) )
|
||||
# define BOOST_EXCEPTION_DISABLE
|
||||
@ -40,18 +41,18 @@ BOOST_NORETURN void throw_exception( std::exception const & e, boost::source_loc
|
||||
|
||||
#endif
|
||||
|
||||
// boost::wrapexcept<E>
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// wrapexcept_add_base
|
||||
|
||||
typedef char (&wrapexcept_s1)[ 1 ];
|
||||
typedef char (&wrapexcept_s2)[ 2 ];
|
||||
|
||||
template<class T> wrapexcept_s1 wrapexcept_is_convertible( T* );
|
||||
template<class T> wrapexcept_s2 wrapexcept_is_convertible( void* );
|
||||
|
||||
template<class E, class B, int I = sizeof( wrapexcept_is_convertible<B>( static_cast< E* >( 0 ) ) ) > struct wrapexcept_add_base;
|
||||
template<class E, class B, std::size_t I = sizeof( wrapexcept_is_convertible<B>( static_cast< E* >( 0 ) ) ) > struct wrapexcept_add_base;
|
||||
|
||||
template<class E, class B> struct wrapexcept_add_base<E, B, 1>
|
||||
{
|
||||
@ -63,12 +64,37 @@ template<class E, class B> struct wrapexcept_add_base<E, B, 2>
|
||||
typedef B type;
|
||||
};
|
||||
|
||||
// wrapexcept_location
|
||||
|
||||
struct wrapexcept_location
|
||||
{
|
||||
wrapexcept_location() {}
|
||||
explicit wrapexcept_location( boost::source_location const& loc ): location_( loc ) {}
|
||||
|
||||
boost::source_location location_;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class E> struct BOOST_SYMBOL_VISIBLE wrapexcept:
|
||||
// wrapexcept<E>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_EXCEPTION)
|
||||
|
||||
template<class E, int cxxstd = 11> struct BOOST_SYMBOL_VISIBLE wrapexcept;
|
||||
|
||||
#else
|
||||
|
||||
template<class E, int cxxstd = 98> struct BOOST_SYMBOL_VISIBLE wrapexcept;
|
||||
|
||||
#endif
|
||||
|
||||
// C++98 version for backward compatibility
|
||||
|
||||
template<class E> struct BOOST_SYMBOL_VISIBLE wrapexcept<E, 98>:
|
||||
public detail::wrapexcept_add_base<E, boost::exception_detail::clone_base>::type,
|
||||
public E,
|
||||
public detail::wrapexcept_add_base<E, boost::exception>::type
|
||||
public detail::wrapexcept_add_base<E, boost::exception>::type,
|
||||
public detail::wrapexcept_location
|
||||
{
|
||||
private:
|
||||
|
||||
@ -96,7 +122,7 @@ public:
|
||||
copy_from( &e );
|
||||
}
|
||||
|
||||
explicit wrapexcept( E const & e, boost::source_location const & loc ): E( e )
|
||||
explicit wrapexcept( E const & e, boost::source_location const & loc ): E( e ), detail::wrapexcept_location( loc )
|
||||
{
|
||||
copy_from( &e );
|
||||
|
||||
@ -130,6 +156,49 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// C++11 version
|
||||
|
||||
template<class E> struct BOOST_SYMBOL_VISIBLE wrapexcept<E, 11>:
|
||||
public E,
|
||||
public detail::wrapexcept_location
|
||||
{
|
||||
private:
|
||||
|
||||
void copy_from( void const* )
|
||||
{
|
||||
}
|
||||
|
||||
void copy_from( boost::exception const* p )
|
||||
{
|
||||
static_cast<boost::exception&>( *this ) = *p;
|
||||
}
|
||||
|
||||
template<class T> void set_info_impl( void*, T const& )
|
||||
{
|
||||
}
|
||||
|
||||
template<class T> void set_info_impl( boost::exception * p, T const& t )
|
||||
{
|
||||
exception_detail::set_info( *p, t );
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
explicit wrapexcept( E const & e ): E( e )
|
||||
{
|
||||
copy_from( &e );
|
||||
}
|
||||
|
||||
explicit wrapexcept( E const & e, boost::source_location const & loc ): E( e ), detail::wrapexcept_location( loc )
|
||||
{
|
||||
copy_from( &e );
|
||||
|
||||
set_info_impl( this, throw_file( loc.file_name() ) );
|
||||
set_info_impl( this, throw_line( loc.line() ) );
|
||||
set_info_impl( this, throw_function( loc.function_name() ) );
|
||||
}
|
||||
};
|
||||
|
||||
// All boost exceptions are required to derive from std::exception,
|
||||
// to ensure compatibility with BOOST_NO_EXCEPTIONS.
|
||||
|
||||
@ -153,24 +222,54 @@ template<class E> BOOST_NORETURN void throw_exception( E const & e, boost::sourc
|
||||
throw e;
|
||||
}
|
||||
|
||||
#else // defined( BOOST_EXCEPTION_DISABLE )
|
||||
#elif !defined(BOOST_NO_CXX11_HDR_EXCEPTION)
|
||||
|
||||
template<class E> BOOST_NORETURN void throw_exception( E const & e )
|
||||
{
|
||||
throw_exception_assert_compatibility( e );
|
||||
throw wrapexcept<E>( e );
|
||||
throw e;
|
||||
}
|
||||
|
||||
template<class E> BOOST_NORETURN void throw_exception( E const & e, boost::source_location const & loc )
|
||||
{
|
||||
throw_exception_assert_compatibility( e );
|
||||
throw wrapexcept<E>( e, loc );
|
||||
throw wrapexcept<E, 11>( e, loc );
|
||||
}
|
||||
|
||||
#else // C++98
|
||||
|
||||
template<class E> BOOST_NORETURN void throw_exception( E const & e )
|
||||
{
|
||||
throw_exception_assert_compatibility( e );
|
||||
throw wrapexcept<E, 98>( e );
|
||||
}
|
||||
|
||||
template<class E> BOOST_NORETURN void throw_exception( E const & e, boost::source_location const & loc )
|
||||
{
|
||||
throw_exception_assert_compatibility( e );
|
||||
throw wrapexcept<E, 98>( e, loc );
|
||||
}
|
||||
|
||||
#endif // defined( BOOST_EXCEPTION_DISABLE )
|
||||
|
||||
#endif // !defined( BOOST_NO_EXCEPTIONS )
|
||||
|
||||
// get_throw_location
|
||||
|
||||
template<class E> boost::source_location get_throw_location( E const& e )
|
||||
{
|
||||
#if defined(BOOST_NO_RTTI)
|
||||
|
||||
return boost::source_location();
|
||||
|
||||
#else
|
||||
|
||||
detail::wrapexcept_location const* p = dynamic_cast< detail::wrapexcept_location const* >( &e );
|
||||
return p? p->location_: boost::source_location();
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
// BOOST_THROW_EXCEPTION
|
||||
|
@ -11,7 +11,8 @@
|
||||
],
|
||||
"description": "A common infrastructure for throwing exceptions from Boost libraries.",
|
||||
"category": [
|
||||
"Miscellaneous"
|
||||
"Emulation",
|
||||
"Error-handling"
|
||||
],
|
||||
"cxxstd": "03"
|
||||
}
|
||||
|
@ -27,13 +27,16 @@ run throw_exception_test2.cpp ;
|
||||
run throw_exception_test3.cpp ;
|
||||
run throw_exception_test4.cpp ;
|
||||
run throw_exception_test5.cpp ;
|
||||
run throw_exception_test6.cpp ;
|
||||
|
||||
lib lib1_throw : lib1_throw.cpp : <define>LIB1_SOURCE=1 <link>shared:<define>LIB1_DYN_LINK=1 : : <link>shared:<define>LIB1_DYN_LINK=1 ;
|
||||
lib lib2_throw : lib2_throw.cpp : <define>LIB2_SOURCE=1 <link>shared:<define>LIB2_DYN_LINK=1 : : <link>shared:<define>LIB2_DYN_LINK=1 ;
|
||||
lib lib3_throw : lib3_throw.cpp : <define>LIB3_SOURCE=1 <link>shared:<define>LIB3_DYN_LINK=1 : : <link>shared:<define>LIB3_DYN_LINK=1 ;
|
||||
lib lib4_throw : lib4_throw.cpp : <define>LIB4_SOURCE=1 <link>shared:<define>LIB4_DYN_LINK=1 : : <link>shared:<define>LIB4_DYN_LINK=1 ;
|
||||
lib lib5_throw : lib5_throw.cpp : <define>LIB5_SOURCE=1 <link>shared:<define>LIB5_DYN_LINK=1 : : <link>shared:<define>LIB5_DYN_LINK=1 ;
|
||||
|
||||
run throw_from_library_test.cpp lib1_throw lib2_throw lib3_throw : : : <link>static : throw_from_library_static ;
|
||||
run throw_from_library_test.cpp lib1_throw lib2_throw lib3_throw : : : <link>shared : throw_from_library_shared ;
|
||||
run throw_from_library_test.cpp lib1_throw lib2_throw lib3_throw lib4_throw lib5_throw : : : <link>static : throw_from_library_static ;
|
||||
run throw_from_library_test.cpp lib1_throw lib2_throw lib3_throw lib4_throw lib5_throw : : : <link>shared : throw_from_library_shared ;
|
||||
|
||||
run throw_exception_nx_test.cpp : : : <exception-handling>off ;
|
||||
run throw_exception_nx_test2.cpp : : : <exception-handling>off ;
|
||||
|
14
test/lib4_throw.cpp
Normal file
14
test/lib4_throw.cpp
Normal file
@ -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 "lib4_throw.hpp"
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
void lib4::f()
|
||||
{
|
||||
boost::throw_exception( lib4::exception() );
|
||||
}
|
36
test/lib4_throw.hpp
Normal file
36
test/lib4_throw.hpp
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef LIB4_THROW_HPP_INCLUDED
|
||||
#define LIB4_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 <boost/exception/exception.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <exception>
|
||||
|
||||
#if defined(LIB4_DYN_LINK)
|
||||
# if defined(LIB4_SOURCE)
|
||||
# define LIB4_DECL BOOST_SYMBOL_EXPORT
|
||||
# else
|
||||
# define LIB4_DECL BOOST_SYMBOL_IMPORT
|
||||
# endif
|
||||
#else
|
||||
# define LIB4_DECL
|
||||
#endif
|
||||
|
||||
namespace lib4
|
||||
{
|
||||
|
||||
struct BOOST_SYMBOL_VISIBLE exception: public std::exception, public boost::exception
|
||||
{
|
||||
};
|
||||
|
||||
LIB4_DECL void f();
|
||||
|
||||
} // namespace lib4
|
||||
|
||||
#endif // #ifndef LIB4_THROW_HPP_INCLUDED
|
14
test/lib5_throw.cpp
Normal file
14
test/lib5_throw.cpp
Normal file
@ -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 "lib5_throw.hpp"
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
void lib5::f()
|
||||
{
|
||||
BOOST_THROW_EXCEPTION( lib5::exception() );
|
||||
}
|
36
test/lib5_throw.hpp
Normal file
36
test/lib5_throw.hpp
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef LIB5_THROW_HPP_INCLUDED
|
||||
#define LIB5_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 <boost/exception/exception.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <exception>
|
||||
|
||||
#if defined(LIB5_DYN_LINK)
|
||||
# if defined(LIB5_SOURCE)
|
||||
# define LIB5_DECL BOOST_SYMBOL_EXPORT
|
||||
# else
|
||||
# define LIB5_DECL BOOST_SYMBOL_IMPORT
|
||||
# endif
|
||||
#else
|
||||
# define LIB5_DECL
|
||||
#endif
|
||||
|
||||
namespace lib5
|
||||
{
|
||||
|
||||
struct BOOST_SYMBOL_VISIBLE exception: public std::exception, public boost::exception
|
||||
{
|
||||
};
|
||||
|
||||
LIB5_DECL void f();
|
||||
|
||||
} // namespace lib5
|
||||
|
||||
#endif // #ifndef LIB5_THROW_HPP_INCLUDED
|
@ -5,27 +5,16 @@
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4702) // unreachable code
|
||||
# pragma warning(disable: 4577) // noexcept used without /EHsc
|
||||
# pragma warning(disable: 4530) // C++ exception handler used
|
||||
#endif
|
||||
|
||||
//#include <boost/exception_ptr.hpp>
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/exception/exception.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
typedef boost::shared_ptr<boost::exception_detail::clone_base const> exception_ptr;
|
||||
|
||||
template<class E> exception_ptr make_exception_ptr( E const& e )
|
||||
{
|
||||
return boost::make_shared< boost::wrapexcept<E> >( e );
|
||||
}
|
||||
#include <boost/exception_ptr.hpp>
|
||||
|
||||
class my_exception: public std::exception {};
|
||||
|
||||
int main()
|
||||
{
|
||||
::make_exception_ptr( my_exception() );
|
||||
boost::make_exception_ptr( my_exception() );
|
||||
}
|
||||
|
||||
namespace boost
|
||||
|
@ -5,29 +5,18 @@
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4702) // unreachable code
|
||||
# pragma warning(disable: 4577) // noexcept used without /EHsc
|
||||
# pragma warning(disable: 4530) // C++ exception handler used
|
||||
#endif
|
||||
|
||||
#define BOOST_EXCEPTION_DISABLE
|
||||
|
||||
//#include <boost/exception_ptr.hpp>
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/exception/exception.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
typedef boost::shared_ptr<boost::exception_detail::clone_base const> exception_ptr;
|
||||
|
||||
template<class E> exception_ptr make_exception_ptr( E const& e )
|
||||
{
|
||||
return boost::make_shared< boost::wrapexcept<E> >( e );
|
||||
}
|
||||
#include <boost/exception_ptr.hpp>
|
||||
|
||||
class my_exception: public std::exception {};
|
||||
|
||||
int main()
|
||||
{
|
||||
::make_exception_ptr( my_exception() );
|
||||
boost::make_exception_ptr( my_exception() );
|
||||
}
|
||||
|
||||
namespace boost
|
||||
|
@ -5,6 +5,7 @@
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4702) // unreachable code
|
||||
# pragma warning(disable: 4577) // noexcept used without /EHsc
|
||||
# pragma warning(disable: 4530) // C++ exception handler used
|
||||
#endif
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
@ -5,6 +5,7 @@
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4702) // unreachable code
|
||||
# pragma warning(disable: 4577) // noexcept used without /EHsc
|
||||
# pragma warning(disable: 4530) // C++ exception handler used
|
||||
#endif
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
@ -27,7 +28,7 @@ void throw_exception( std::exception const &, boost::source_location const & loc
|
||||
int r = 0;
|
||||
|
||||
if( std::strcmp( loc.file_name(), __FILE__ ) != 0 ) ++r;
|
||||
if( loc.line() != 18 ) ++r;
|
||||
if( loc.line() != 19 ) ++r;
|
||||
|
||||
std::exit( r );
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4702) // unreachable code
|
||||
# pragma warning(disable: 4577) // noexcept used without /EHsc
|
||||
# pragma warning(disable: 4530) // C++ exception handler used
|
||||
#endif
|
||||
|
||||
// Make sure that simple inclusion does not
|
||||
|
@ -26,12 +26,20 @@ class my_exception3: public std::exception, public virtual boost::exception
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_THROWS( boost::throw_exception( my_exception() ), boost::exception );
|
||||
BOOST_TEST_THROWS( boost::throw_exception( my_exception() ), my_exception );
|
||||
|
||||
BOOST_TEST_THROWS( boost::throw_exception( my_exception2() ), my_exception2 );
|
||||
BOOST_TEST_THROWS( boost::throw_exception( my_exception2() ), boost::exception );
|
||||
|
||||
BOOST_TEST_THROWS( boost::throw_exception( my_exception3() ), my_exception3 );
|
||||
BOOST_TEST_THROWS( boost::throw_exception( my_exception3() ), boost::exception );
|
||||
|
||||
BOOST_TEST_THROWS( BOOST_THROW_EXCEPTION( my_exception() ), boost::exception );
|
||||
BOOST_TEST_THROWS( BOOST_THROW_EXCEPTION( my_exception() ), my_exception );
|
||||
|
||||
BOOST_TEST_THROWS( BOOST_THROW_EXCEPTION( my_exception2() ), my_exception2 );
|
||||
BOOST_TEST_THROWS( BOOST_THROW_EXCEPTION( my_exception2() ), boost::exception );
|
||||
|
||||
BOOST_TEST_THROWS( BOOST_THROW_EXCEPTION( my_exception3() ), my_exception3 );
|
||||
BOOST_TEST_THROWS( BOOST_THROW_EXCEPTION( my_exception3() ), boost::exception );
|
||||
|
||||
return boost::report_errors();
|
||||
|
@ -44,7 +44,6 @@ int main()
|
||||
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
|
||||
@ -80,7 +79,6 @@ int main()
|
||||
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
|
||||
|
@ -9,10 +9,6 @@
|
||||
#include <boost/exception/get_error_info.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
class my_exception: public std::exception
|
||||
{
|
||||
};
|
||||
|
||||
class my_exception2: public std::exception, public boost::exception
|
||||
{
|
||||
};
|
||||
@ -25,7 +21,7 @@ int main()
|
||||
{
|
||||
try
|
||||
{
|
||||
BOOST_THROW_EXCEPTION( my_exception() );
|
||||
BOOST_THROW_EXCEPTION( my_exception2() );
|
||||
}
|
||||
catch( boost::exception const & x )
|
||||
{
|
||||
@ -40,7 +36,7 @@ int main()
|
||||
int const * line = boost::get_error_info<boost::throw_line>( x );
|
||||
|
||||
BOOST_TEST( line != 0 );
|
||||
BOOST_TEST_EQ( *line, 28 );
|
||||
BOOST_TEST_EQ( *line, 24 );
|
||||
}
|
||||
|
||||
{
|
||||
@ -50,10 +46,14 @@ int main()
|
||||
BOOST_TEST_CSTR_EQ( *function, BOOST_CURRENT_FUNCTION );
|
||||
}
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
BOOST_ERROR( "BOOST_THROW_EXCEPTION( my_exception2() ) didn't throw boost::exception" );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
BOOST_THROW_EXCEPTION( my_exception2() );
|
||||
BOOST_THROW_EXCEPTION( my_exception3() );
|
||||
}
|
||||
catch( boost::exception const & x )
|
||||
{
|
||||
@ -78,33 +78,9 @@ int main()
|
||||
BOOST_TEST_CSTR_EQ( *function, BOOST_CURRENT_FUNCTION );
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
catch( ... )
|
||||
{
|
||||
BOOST_THROW_EXCEPTION( my_exception3() );
|
||||
}
|
||||
catch( boost::exception const & x )
|
||||
{
|
||||
{
|
||||
char const * const * file = boost::get_error_info<boost::throw_file>( x );
|
||||
|
||||
BOOST_TEST( file != 0 );
|
||||
BOOST_TEST_CSTR_EQ( *file, __FILE__ );
|
||||
}
|
||||
|
||||
{
|
||||
int const * line = boost::get_error_info<boost::throw_line>( x );
|
||||
|
||||
BOOST_TEST( line != 0 );
|
||||
BOOST_TEST_EQ( *line, 84 );
|
||||
}
|
||||
|
||||
{
|
||||
char const * const * function = boost::get_error_info<boost::throw_function>( x );
|
||||
|
||||
BOOST_TEST( function != 0 );
|
||||
BOOST_TEST_CSTR_EQ( *function, BOOST_CURRENT_FUNCTION );
|
||||
}
|
||||
BOOST_ERROR( "BOOST_THROW_EXCEPTION( my_exception3() ) didn't throw boost::exception" );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
|
53
test/throw_exception_test6.cpp
Normal file
53
test/throw_exception_test6.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
// Copyright 2018, 2022 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
class my_exception: public std::exception
|
||||
{
|
||||
};
|
||||
|
||||
class my_exception2: public std::exception, public virtual boost::exception
|
||||
{
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
try
|
||||
{
|
||||
BOOST_THROW_EXCEPTION( my_exception() );
|
||||
}
|
||||
catch( std::exception const & x )
|
||||
{
|
||||
boost::source_location loc = boost::get_throw_location( x );
|
||||
|
||||
BOOST_TEST_CSTR_EQ( loc.file_name(), __FILE__ );
|
||||
BOOST_TEST_EQ( loc.line(), 20 );
|
||||
BOOST_TEST_CSTR_EQ( loc.function_name(), BOOST_CURRENT_FUNCTION );
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
BOOST_ERROR( "'BOOST_THROW_EXCEPTION( my_exception() )' didn't throw 'std::exception'" );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
BOOST_THROW_EXCEPTION( my_exception2() );
|
||||
}
|
||||
catch( boost::exception const & x )
|
||||
{
|
||||
boost::source_location loc = boost::get_throw_location( x );
|
||||
|
||||
BOOST_TEST_CSTR_EQ( loc.file_name(), __FILE__ );
|
||||
BOOST_TEST_EQ( loc.line(), 37 );
|
||||
BOOST_TEST_CSTR_EQ( loc.function_name(), BOOST_CURRENT_FUNCTION );
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
BOOST_ERROR( "'BOOST_THROW_EXCEPTION( my_exception2() )' didn't throw 'boost::exception'" );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
@ -20,6 +20,8 @@
|
||||
#include "lib1_throw.hpp"
|
||||
#include "lib2_throw.hpp"
|
||||
#include "lib3_throw.hpp"
|
||||
#include "lib4_throw.hpp"
|
||||
#include "lib5_throw.hpp"
|
||||
#include <boost/exception/exception.hpp>
|
||||
#include <boost/exception_ptr.hpp>
|
||||
#include <boost/exception/get_error_info.hpp>
|
||||
@ -30,12 +32,14 @@ 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 );
|
||||
BOOST_TEST_THROWS( lib4::f(), lib4::exception );
|
||||
BOOST_TEST_THROWS( lib5::f(), lib5::exception );
|
||||
}
|
||||
|
||||
void test_catch_by_exception()
|
||||
{
|
||||
BOOST_TEST_THROWS( lib2::f(), boost::exception );
|
||||
BOOST_TEST_THROWS( lib3::f(), boost::exception );
|
||||
BOOST_TEST_THROWS( lib4::f(), boost::exception );
|
||||
BOOST_TEST_THROWS( lib5::f(), boost::exception );
|
||||
}
|
||||
|
||||
void test_exception_ptr()
|
||||
@ -49,7 +53,6 @@ void test_exception_ptr()
|
||||
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
|
||||
@ -61,6 +64,29 @@ void test_exception_ptr()
|
||||
boost::exception_ptr p = boost::current_exception();
|
||||
|
||||
BOOST_TEST_THROWS( boost::rethrow_exception( p ), lib3::exception );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
lib4::f();
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
boost::exception_ptr p = boost::current_exception();
|
||||
|
||||
BOOST_TEST_THROWS( boost::rethrow_exception( p ), lib4::exception );
|
||||
BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
lib5::f();
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
boost::exception_ptr p = boost::current_exception();
|
||||
|
||||
BOOST_TEST_THROWS( boost::rethrow_exception( p ), lib5::exception );
|
||||
BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception );
|
||||
}
|
||||
}
|
||||
@ -69,7 +95,7 @@ void test_throw_line()
|
||||
{
|
||||
try
|
||||
{
|
||||
lib3::f();
|
||||
lib5::f();
|
||||
}
|
||||
catch( boost::exception const & x )
|
||||
{
|
||||
|
Reference in New Issue
Block a user