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

@ -4,6 +4,12 @@
%module(threads="1") threads_exception
// throw is invalid in C++17 and later, only SWIG to use it
#define TESTCASE_THROW(TYPES...) throw(TYPES)
%{
#define TESTCASE_THROW(TYPES...)
%}
%{
struct A {};
%}
@ -11,14 +17,6 @@ struct A {};
%inline %{
#include <string>
#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
class Exc {
public:
Exc(int c, const char *m) {
@ -32,24 +30,24 @@ public:
class Test {
public:
int simple() throw(int) {
int simple() TESTCASE_THROW(int) {
throw(37);
return 1;
}
int message() throw(const char *) {
int message() TESTCASE_THROW(const char *) {
throw("I died.");
return 1;
}
int hosed() throw(Exc) {
int hosed() TESTCASE_THROW(Exc) {
throw(Exc(42,"Hosed"));
return 1;
}
int unknown() throw(A*) {
int unknown() TESTCASE_THROW(A*) {
static A a;
throw &a;
return 1;
}
int multi(int x) throw(int, const char *, Exc) {
int multi(int x) TESTCASE_THROW(int, const char *, Exc) {
if (x == 1) throw(37);
if (x == 2) throw("Bleah!");
if (x == 3) throw(Exc(42,"No-go-diggy-die"));
@ -62,11 +60,4 @@ bool is_python_builtin() { return true; }
#else
bool is_python_builtin() { return false; }
#endif
#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
%}