diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2018-05-03 18:57:46 +0100 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2018-05-04 20:02:13 +0100 |
commit | 35b792daed7bebaadd74c2f48a66c694fa4d70ed (patch) | |
tree | 5bb67ca1aa227815a9932b040d644dd8a824aeb0 /Examples/test-suite/li_std_except.i | |
parent | ebd6558a30f9e7094fa8dd8e39e5a48834a28ccb (diff) | |
download | swig-35b792daed7bebaadd74c2f48a66c694fa4d70ed.tar.gz |
test-suite support for C++17: exception specification throw removal
Diffstat (limited to 'Examples/test-suite/li_std_except.i')
-rw-r--r-- | Examples/test-suite/li_std_except.i | 52 |
1 files changed, 19 insertions, 33 deletions
diff --git a/Examples/test-suite/li_std_except.i b/Examples/test-suite/li_std_except.i index 8c96a11f8..fe621e3b4 100644 --- a/Examples/test-suite/li_std_except.i +++ b/Examples/test-suite/li_std_except.i @@ -2,17 +2,12 @@ %include <std_except.i> +// throw is invalid in C++17 and later, only SWIG to use it +#define TESTCASE_THROW(TYPES...) throw(TYPES) %{ -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 -#endif +#define TESTCASE_THROW(TYPES...) %} - %inline %{ struct E1 : public std::exception { @@ -23,32 +18,23 @@ }; struct Test { - int foo1() throw(std::bad_exception) { return 0; } - int foo2() throw(std::logic_error) { return 0; } - int foo3() throw(E1) { return 0; } - int foo4() throw(E2) { return 0; } + int foo1() TESTCASE_THROW(std::bad_exception) { return 0; } + int foo2() TESTCASE_THROW(std::logic_error) { return 0; } + int foo3() TESTCASE_THROW(E1) { return 0; } + int foo4() TESTCASE_THROW(E2) { return 0; } // all the STL exceptions... - void throw_bad_cast() throw(std::bad_cast) { throw std::bad_cast(); } - void throw_bad_exception() throw(std::bad_exception) { throw std::bad_exception(); } - void throw_domain_error() throw(std::domain_error) { throw std::domain_error("oops"); } - void throw_exception() throw(std::exception) { throw std::exception(); } - void throw_invalid_argument() throw(std::invalid_argument) { throw std::invalid_argument("oops"); } - void throw_length_error() throw(std::length_error) { throw std::length_error("oops"); } - void throw_logic_error() throw(std::logic_error) { throw std::logic_error("oops"); } - void throw_out_of_range() throw(std::out_of_range) { throw std::out_of_range("oops"); } - void throw_overflow_error() throw(std::overflow_error) { throw std::overflow_error("oops"); } - void throw_range_error() throw(std::range_error) { throw std::range_error("oops"); } - void throw_runtime_error() throw(std::runtime_error) { throw std::runtime_error("oops"); } - void throw_underflow_error() throw(std::underflow_error) { throw std::underflow_error("oops"); } + void throw_bad_cast() TESTCASE_THROW(std::bad_cast) { throw std::bad_cast(); } + void throw_bad_exception() TESTCASE_THROW(std::bad_exception) { throw std::bad_exception(); } + void throw_domain_error() TESTCASE_THROW(std::domain_error) { throw std::domain_error("oops"); } + void throw_exception() TESTCASE_THROW(std::exception) { throw std::exception(); } + void throw_invalid_argument() TESTCASE_THROW(std::invalid_argument) { throw std::invalid_argument("oops"); } + void throw_length_error() TESTCASE_THROW(std::length_error) { throw std::length_error("oops"); } + void throw_logic_error() TESTCASE_THROW(std::logic_error) { throw std::logic_error("oops"); } + void throw_out_of_range() TESTCASE_THROW(std::out_of_range) { throw std::out_of_range("oops"); } + void throw_overflow_error() TESTCASE_THROW(std::overflow_error) { throw std::overflow_error("oops"); } + void throw_range_error() TESTCASE_THROW(std::range_error) { throw std::range_error("oops"); } + void throw_runtime_error() TESTCASE_THROW(std::runtime_error) { throw std::runtime_error("oops"); } + void throw_underflow_error() TESTCASE_THROW(std::underflow_error) { throw std::underflow_error("oops"); } }; %} - -%{ -#if defined(_MSC_VER) - #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic pop -#endif -%} |