Merge remote branch 'upstream/master' into perl5-directors-minimal

This commit is contained in:
Robert Stone 2013-11-21 19:35:23 -08:00
commit 0db26ffee2
11 changed files with 427 additions and 128 deletions

View file

@ -0,0 +1,20 @@
%module c_delete
/* check C++ delete keyword is okay in C wrappers */
#pragma SWIG nowarn=SWIGWARN_PARSE_KEYWORD
#if !defined(SWIGOCTAVE) /* Octave compiles wrappers as C++ */
%inline %{
struct delete {
int delete;
};
%}
%rename(DeleteGlobalVariable) delete;
%inline %{
int delete = 0;
%}
#endif

View file

@ -0,0 +1,11 @@
%module c_delete_function
/* check C++ delete keyword is okay in C wrappers */
#if !defined(SWIGOCTAVE) /* Octave compiles wrappers as C++ */
%inline %{
double delete(double d) { return d; }
%}
#endif

View file

@ -491,6 +491,7 @@ CPP11_TEST_CASES = \
cpp11_initializer_list \
cpp11_initializer_list_extend \
cpp11_lambda_functions \
cpp11_noexcept \
cpp11_null_pointer_constant \
cpp11_raw_string_literals \
cpp11_rvalue_reference \
@ -552,6 +553,8 @@ endif
C_TEST_CASES += \
arrays \
bom_utf8 \
c_delete \
c_delete_function \
char_constant \
const_const \
constant_expr \

View file

@ -1,9 +1,12 @@
/* This testcase checks whether SWIG correctly parses the default and delete
keywords which keep or remove default C++ object construction functions. */
/* This testcase checks whether SWIG correctly parses C++11 explicitly defaulted functions and deleted functions */
%module cpp11_default_delete
%{
#include <stdlib.h>
%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED, SWIGWARN_LANG_OVERLOAD_SHADOW) trivial::trivial(trivial&&);
%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED, SWIGWARN_LANG_OVERLOAD_SHADOW) trivial::operator =(trivial&&);
%rename(Assignment) *::operator=;
%inline %{
class NonCopyable {
public:
@ -14,11 +17,65 @@ public:
};
struct A1 {
void f(int i);
void f(double i) = delete; /* Don't cast double to int. Compiler returns an error */
void func(int i) {}
A1() = default;
~A1() = default;
void func(double i) = delete; /* Don't cast double to int. Compiler returns an error */
private:
A1(const A1&);
};
A1::A1(const A1&) = default;
struct A2 {
void f(int i);
template<class T> void f(T) = delete; /* Only accept int */
void func(int i) {}
virtual void fff(int) = delete;
virtual ~A2() = default;
template<class T> void func(T) = delete;
};
struct trivial {
trivial() = default;
trivial(const trivial&) = default;
trivial(trivial&&) = default;
trivial& operator=(const trivial&) = default;
trivial& operator=(trivial&&) = default;
~trivial() = default;
};
struct nontrivial1 {
nontrivial1();
};
nontrivial1::nontrivial1() = default;
struct sometype {
sometype() = delete;
sometype(int) = delete;
sometype(double);
};
sometype::sometype(double) {}
/* Not working with prerelease of gcc-4.8
struct nonew {
void *operator new(std::size_t) = delete;
void *operator new[](std::size_t) = delete;
};
*/
struct moveonly {
moveonly() = default;
moveonly(const moveonly&) = delete;
moveonly(moveonly&&) = default;
moveonly& operator=(const moveonly&) = delete;
moveonly& operator=(moveonly&&) = default;
~moveonly() = default;
};
struct ConstructorThrow {
ConstructorThrow() throw() = default;
ConstructorThrow(const ConstructorThrow&) throw() = delete;
ConstructorThrow(ConstructorThrow&&) throw() = delete;
ConstructorThrow& operator=(const ConstructorThrow&) throw() = delete;
~ConstructorThrow() throw() = default;
};
%}

View file

@ -0,0 +1,49 @@
%module cpp11_noexcept
%ignore NoExceptClass(NoExceptClass&&);
%rename(Assignment) NoExceptClass::operator=;
%inline %{
extern "C" void global_noexcept(int, bool) noexcept;
struct NoExceptClass {
static const bool VeryTrue = true;
NoExceptClass() noexcept {}
NoExceptClass(const NoExceptClass&) noexcept {}
NoExceptClass(NoExceptClass&&) noexcept {}
NoExceptClass& operator=(const NoExceptClass&) noexcept {}
~NoExceptClass() noexcept {}
void noex0() noexcept {}
void noex1() noexcept(sizeof(int) == 4) {}
void noex2() noexcept(true) {}
void noex3() noexcept(false) {}
void noex4() noexcept(VeryTrue) {}
template<typename T> void template_noexcept(T) noexcept {}
void noo1() const noexcept {}
static void noo2() noexcept {}
virtual void noo3() const noexcept {}
virtual void noo4() const noexcept = delete;
virtual void noo5() const throw() = delete;
};
struct NoExceptAbstract {
virtual void noo4() const noexcept = 0;
virtual ~NoExceptAbstract() noexcept = 0;
};
struct NoExceptDefaultDelete {
template<typename T> NoExceptDefaultDelete(T) noexcept = delete;
NoExceptDefaultDelete() noexcept = default;
NoExceptDefaultDelete(const NoExceptDefaultDelete&) noexcept = delete;
NoExceptDefaultDelete(NoExceptDefaultDelete&&) = delete;
NoExceptDefaultDelete& operator=(const NoExceptDefaultDelete&) = delete;
~NoExceptDefaultDelete() noexcept = default;
};
%}