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

@ -1,13 +1,9 @@
%module throw_exception
// 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...)
%}
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Namespace::enum1;
@ -34,45 +30,45 @@ namespace Namespace {
}
class Foo {
public:
void test_int() throw(int) {
void test_int() TESTCASE_THROW(int) {
throw 37;
}
void test_msg() throw(const char *) {
void test_msg() TESTCASE_THROW(const char *) {
throw "Dead";
}
void test_cls() throw(CError) {
void test_cls() TESTCASE_THROW(CError) {
throw CError();
}
void test_cls_ptr() throw(CError *) {
void test_cls_ptr() TESTCASE_THROW(CError *) {
static CError StaticError;
throw &StaticError;
}
void test_cls_ref() throw(CError &) {
void test_cls_ref() TESTCASE_THROW(CError &) {
static CError StaticError;
throw StaticError;
}
void test_cls_td() throw(Namespace::ErrorTypedef) {
void test_cls_td() TESTCASE_THROW(Namespace::ErrorTypedef) {
throw CError();
}
void test_cls_ptr_td() throw(Namespace::ErrorPtr) {
void test_cls_ptr_td() TESTCASE_THROW(Namespace::ErrorPtr) {
static CError StaticError;
throw &StaticError;
}
void test_cls_ref_td() throw(Namespace::ErrorRef) {
void test_cls_ref_td() TESTCASE_THROW(Namespace::ErrorRef) {
static CError StaticError;
throw StaticError;
}
void test_array() throw(Namespace::IntArray) {
void test_array() TESTCASE_THROW(Namespace::IntArray) {
static Namespace::IntArray array;
for (int i=0; i<10; i++) {
array[i] = i;
}
throw array;
}
void test_enum() throw(Namespace::EnumTest) {
void test_enum() TESTCASE_THROW(Namespace::EnumTest) {
throw Namespace::enum2;
}
void test_multi(int x) throw(int, const char *, CError) {
void test_multi(int x) TESTCASE_THROW(int, const char *, CError) {
if (x == 1) throw 37;
if (x == 2) throw "Dead";
if (x == 3) throw CError();
@ -81,11 +77,3 @@ public:
%}
%{
#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
%}