test-suite support for C++17: exception specification throw removal

This commit is contained in:
William S Fulton 2018-05-03 18:57:46 +01:00
commit 35b792daed
23 changed files with 190 additions and 419 deletions

View file

@ -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
%}