aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Stone <talby@trap.mtview.ca.us>2013-11-21 19:35:23 -0800
committerRobert Stone <talby@trap.mtview.ca.us>2013-11-21 19:35:23 -0800
commit0db26ffee2a21f40d3192255cfb5bb1da7dc4c71 (patch)
tree9901f994c38527af4cee10ab941c131e65b34c8f
parentbb6ab0318cb7bf9c7a6065be8b884ae0bbbca1ce (diff)
parentfcd0480364ba932cf5e9eabb34c7c048f146e758 (diff)
downloadswig-0db26ffee2a21f40d3192255cfb5bb1da7dc4c71.tar.gz
Merge remote branch 'upstream/master' into perl5-directors-minimal
-rw-r--r--.travis.yml1
-rw-r--r--Doc/Manual/CPlusPlus11.html187
-rw-r--r--Examples/test-suite/c_delete.i20
-rw-r--r--Examples/test-suite/c_delete_function.i11
-rw-r--r--Examples/test-suite/common.mk3
-rw-r--r--Examples/test-suite/cpp11_default_delete.i73
-rw-r--r--Examples/test-suite/cpp11_noexcept.i49
-rw-r--r--Lib/csharp/csharpkw.swg3
-rw-r--r--Source/CParse/cscanner.c5
-rw-r--r--Source/CParse/parser.y163
-rw-r--r--Source/Modules/allocate.cxx26
11 files changed, 420 insertions, 121 deletions
diff --git a/.travis.yml b/.travis.yml
index 0a3aa1893..2b860cc9e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -33,6 +33,7 @@ matrix:
allow_failures:
# None
before_install:
+ - date -u
- lsb_release -a
- uname -a
- sudo apt-get -qq update
diff --git a/Doc/Manual/CPlusPlus11.html b/Doc/Manual/CPlusPlus11.html
index 3caec748e..0d2f22aff 100644
--- a/Doc/Manual/CPlusPlus11.html
+++ b/Doc/Manual/CPlusPlus11.html
@@ -10,45 +10,46 @@
<!-- INDEX -->
<div class="sectiontoc">
<ul>
-<li><a href="#CPlusPlus11_Introduction">Introduction</a>
-<li><a href="#CPlusPlus11_Core_language_changes">Core language changes</a>
+<li><a href="#CPlusPlus11_introduction">Introduction</a>
+<li><a href="#CPlusPlus11_core_language_changes">Core language changes</a>
<ul>
-<li><a href="#CPlusPlus11_Rvalue_reference_and_move_semantics">Rvalue reference and move semantics</a>
-<li><a href="#CPlusPlus11_Generalized_constant_expressions">Generalized constant expressions</a>
-<li><a href="#CPlusPlus11_Extern_template">Extern template</a>
-<li><a href="#CPlusPlus11_Initializer_lists">Initializer lists</a>
-<li><a href="#CPlusPlus11_Uniform_initialization">Uniform initialization</a>
-<li><a href="#CPlusPlus11_Type_inference">Type inference</a>
-<li><a href="#CPlusPlus11_Range_based_for_loop">Range-based for-loop</a>
-<li><a href="#CPlusPlus11_Lambda_functions_and_expressions">Lambda functions and expressions</a>
-<li><a href="#CPlusPlus11_Alternate_function_syntax">Alternate function syntax</a>
-<li><a href="#CPlusPlus11_Object_construction_improvement">Object construction improvement</a>
-<li><a href="#CPlusPlus11_Null_pointer_constant">Null pointer constant</a>
-<li><a href="#CPlusPlus11_Strongly_typed_enumerations">Strongly typed enumerations</a>
-<li><a href="#CPlusPlus11_Double_angle_brackets">Double angle brackets</a>
-<li><a href="#CPlusPlus11_Explicit_conversion_operators">Explicit conversion operators</a>
-<li><a href="#CPlusPlus11_Alias_templates">Alias templates</a>
-<li><a href="#CPlusPlus11_Unrestricted_unions">Unrestricted unions</a>
-<li><a href="#CPlusPlus11_Variadic_templates">Variadic templates</a>
-<li><a href="#CPlusPlus11_New_string_literals">New string literals</a>
-<li><a href="#CPlusPlus11_User_defined_literals">User-defined literals</a>
-<li><a href="#CPlusPlus11_Thread_local_storage">Thread-local storage</a>
-<li><a href="#CPlusPlus11_Defaulting/deleting_of_standard_functions_on_C++_objects">Defaulting/deleting of standard functions on C++ objects</a>
-<li><a href="#CPlusPlus11_Type_long_long_int">Type long long int</a>
-<li><a href="#CPlusPlus11_Static_assertions">Static assertions</a>
-<li><a href="#CPlusPlus11_Allow_sizeof_to_work_on_members_of_classes_without_an_explicit_object">Allow sizeof to work on members of classes without an explicit object</a>
+<li><a href="#CPlusPlus11_rvalue_reference_and_move_semantics">Rvalue reference and move semantics</a>
+<li><a href="#CPlusPlus11_generalized_constant_expressions">Generalized constant expressions</a>
+<li><a href="#CPlusPlus11_extern_template">Extern template</a>
+<li><a href="#CPlusPlus11_initializer_lists">Initializer lists</a>
+<li><a href="#CPlusPlus11_uniform_initialization">Uniform initialization</a>
+<li><a href="#CPlusPlus11_type_inference">Type inference</a>
+<li><a href="#CPlusPlus11_range_based_for_loop">Range-based for-loop</a>
+<li><a href="#CPlusPlus11_lambda_functions_and_expressions">Lambda functions and expressions</a>
+<li><a href="#CPlusPlus11_alternate_function_syntax">Alternate function syntax</a>
+<li><a href="#CPlusPlus11_object_construction_improvement">Object construction improvement</a>
+<li><a href="#CPlusPlus11_null_pointer_constant">Null pointer constant</a>
+<li><a href="#CPlusPlus11_strongly_typed_enumerations">Strongly typed enumerations</a>
+<li><a href="#CPlusPlus11_double_angle_brackets">Double angle brackets</a>
+<li><a href="#CPlusPlus11_explicit_conversion_operators">Explicit conversion operators</a>
+<li><a href="#CPlusPlus11_alias_templates">Alias templates</a>
+<li><a href="#CPlusPlus11_unrestricted_unions">Unrestricted unions</a>
+<li><a href="#CPlusPlus11_variadic_templates">Variadic templates</a>
+<li><a href="#CPlusPlus11_new_string_literals">New string literals</a>
+<li><a href="#CPlusPlus11_user_defined_literals">User-defined literals</a>
+<li><a href="#CPlusPlus11_thread_local_storage">Thread-local storage</a>
+<li><a href="#CPlusPlus11_defaulted_deleted">Explicitly defaulted functions and deleted functions</a>
+<li><a href="#CPlusPlus11_type_long_long_int">Type long long int</a>
+<li><a href="#CPlusPlus11_static_assertions">Static assertions</a>
+<li><a href="#CPlusPlus11_allow_sizeof_to_work_on_members_of_classes_without_an_explicit_object">Allow sizeof to work on members of classes without an explicit object</a>
+<li><a href="#CPlusPlus11_noexcept">Exception specifications and noexcept</a>
</ul>
-<li><a href="#CPlusPlus11_Standard_library_changes">Standard library changes</a>
+<li><a href="#CPlusPlus11_standard_library_changes">Standard library changes</a>
<ul>
-<li><a href="#CPlusPlus11_Threading_facilities">Threading facilities</a>
-<li><a href="#CPlusPlus11_Tuple_types">Tuple types and hash tables</a>
-<li><a href="#CPlusPlus11_Regular_expressions">Regular expressions</a>
-<li><a href="#CPlusPlus11_General_purpose_smart_pointers">General-purpose smart pointers</a>
-<li><a href="#CPlusPlus11_Extensible_random_number_facility">Extensible random number facility</a>
-<li><a href="#CPlusPlus11_Wrapper_reference">Wrapper reference</a>
-<li><a href="#CPlusPlus11_Polymorphous_wrappers_for_function_objects">Polymorphous wrappers for function objects</a>
-<li><a href="#CPlusPlus11_Type_traits_for_metaprogramming">Type traits for metaprogramming</a>
-<li><a href="#CPlusPlus11_Uniform_method_for_computing_return_type_of_function_objects">Uniform method for computing return type of function objects</a>
+<li><a href="#CPlusPlus11_threading_facilities">Threading facilities</a>
+<li><a href="#CPlusPlus11_tuple_types">Tuple types and hash tables</a>
+<li><a href="#CPlusPlus11_regular_expressions">Regular expressions</a>
+<li><a href="#CPlusPlus11_general_purpose_smart_pointers">General-purpose smart pointers</a>
+<li><a href="#CPlusPlus11_extensible_random_number_facility">Extensible random number facility</a>
+<li><a href="#CPlusPlus11_wrapper_reference">Wrapper reference</a>
+<li><a href="#CPlusPlus11_polymorphous_wrappers_for_function_objects">Polymorphous wrappers for function objects</a>
+<li><a href="#CPlusPlus11_type_traits_for_metaprogramming">Type traits for metaprogramming</a>
+<li><a href="#CPlusPlus11_uniform_method_for_computing_return_type_of_function_objects">Uniform method for computing return type of function objects</a>
</ul>
</ul>
</div>
@@ -56,7 +57,7 @@
-<H2><a name="CPlusPlus11_Introduction"></a>7.1 Introduction</H2>
+<H2><a name="CPlusPlus11_introduction"></a>7.1 Introduction</H2>
<p>This chapter gives you a brief overview about the SWIG
@@ -68,10 +69,10 @@ Google Summer of Code 2009 period.</p>
new STL types (unordered_ containers, result_of, tuples) are not supported
yet.</p>
-<H2><a name="CPlusPlus11_Core_language_changes"></a>7.2 Core language changes</H2>
+<H2><a name="CPlusPlus11_core_language_changes"></a>7.2 Core language changes</H2>
-<H3><a name="CPlusPlus11_Rvalue_reference_and_move_semantics"></a>7.2.1 Rvalue reference and move semantics</H3>
+<H3><a name="CPlusPlus11_rvalue_reference_and_move_semantics"></a>7.2.1 Rvalue reference and move semantics</H3>
<p>SWIG correctly parses the new operator &amp;&amp; the same as the reference operator &amp;.</p>
@@ -87,7 +88,7 @@ class MyClass {
};
</pre></div>
-<H3><a name="CPlusPlus11_Generalized_constant_expressions"></a>7.2.2 Generalized constant expressions</H3>
+<H3><a name="CPlusPlus11_generalized_constant_expressions"></a>7.2.2 Generalized constant expressions</H3>
<p>SWIG correctly parses the keyword <tt>constexpr</tt>, but ignores its functionality. Constant functions cannot be used as constants.</p>
@@ -105,7 +106,7 @@ constexpr int myConstFunc() { return MY_CONST; }
const int a = MY_CONST; // ok
</pre></div>
-<H3><a name="CPlusPlus11_Extern_template"></a>7.2.3 Extern template</H3>
+<H3><a name="CPlusPlus11_extern_template"></a>7.2.3 Extern template</H3>
<p>SWIG correctly parses the keywords <tt>extern template</tt>. However, the explicit template instantiation is not used by SWIG, a <tt>%template</tt> is still required.</p>
@@ -123,7 +124,8 @@ public:
};
</pre></div>
-<H3><a name="CPlusPlus11_Initializer_lists"></a>7.2.4 Initializer lists</H3>
+<H3><a name="CPlusPlus11_initializer_lists"></a>7.2.4 Initializer lists</H3>
+
<p>
Initializer lists are very much a C++ compiler construct and are not very accessible from wrappers as
@@ -254,7 +256,7 @@ Note that the default typemap for <tt>std::initializer_list</tt> does nothing bu
and hence any user supplied typemaps will override it and suppress the warning.
</p>
-<H3><a name="CPlusPlus11_Uniform_initialization"></a>7.2.5 Uniform initialization</H3>
+<H3><a name="CPlusPlus11_uniform_initialization"></a>7.2.5 Uniform initialization</H3>
<p>The curly brackets {} for member initialization are fully
@@ -287,7 +289,7 @@ AltStruct var2{2, 4.3}; // calls the constructor
142.15
</pre></div>
-<H3><a name="CPlusPlus11_Type_inference"></a>7.2.6 Type inference</H3>
+<H3><a name="CPlusPlus11_type_inference"></a>7.2.6 Type inference</H3>
<p>SWIG supports <tt>decltype()</tt> with some limitations. Single
@@ -304,13 +306,13 @@ int i; int j;
decltype(i+j) k; // syntax error
</pre></div>
-<H3><a name="CPlusPlus11_Range_based_for_loop"></a>7.2.7 Range-based for-loop</H3>
+<H3><a name="CPlusPlus11_range_based_for_loop"></a>7.2.7 Range-based for-loop</H3>
<p>This feature is part of the implementation block only. SWIG
ignores it.</p>
-<H3><a name="CPlusPlus11_Lambda_functions_and_expressions"></a>7.2.8 Lambda functions and expressions</H3>
+<H3><a name="CPlusPlus11_lambda_functions_and_expressions"></a>7.2.8 Lambda functions and expressions</H3>
<p>SWIG correctly parses most of the Lambda functions syntax. For example:</p>
@@ -336,7 +338,7 @@ auto six = [](int x, int y) { return x+y; }(4, 2);
Better support should be available in a later release.
</p>
-<H3><a name="CPlusPlus11_Alternate_function_syntax"></a>7.2.9 Alternate function syntax</H3>
+<H3><a name="CPlusPlus11_alternate_function_syntax"></a>7.2.9 Alternate function syntax</H3>
<p>SWIG fully supports the new definition of functions. For example:</p>
@@ -371,7 +373,7 @@ auto SomeStruct::FuncName(int x, int y) -&gt; int {
auto square(float a, float b) -&gt; decltype(a);
</pre></div>
-<H3><a name="CPlusPlus11_Object_construction_improvement"></a>7.2.10 Object construction improvement</H3>
+<H3><a name="CPlusPlus11_object_construction_improvement"></a>7.2.10 Object construction improvement</H3>
<p>
@@ -412,12 +414,12 @@ class DerivedClass: public BaseClass {
};
</pre></div>
-<H3><a name="CPlusPlus11_Null_pointer_constant"></a>7.2.11 Null pointer constant</H3>
+<H3><a name="CPlusPlus11_null_pointer_constant"></a>7.2.11 Null pointer constant</H3>
<p>The <tt>nullptr</tt> constant is largely unimportant in wrappers. In the few places it has an effect, it is treated like <tt>NULL</tt>.</p>
-<H3><a name="CPlusPlus11_Strongly_typed_enumerations"></a>7.2.12 Strongly typed enumerations</H3>
+<H3><a name="CPlusPlus11_strongly_typed_enumerations"></a>7.2.12 Strongly typed enumerations</H3>
<p>SWIG parses the new <tt>enum class</tt> syntax and forward declarator for the enums:</p>
@@ -468,7 +470,7 @@ class AllColors {
};
</pre></div>
-<H3><a name="CPlusPlus11_Double_angle_brackets"></a>7.2.13 Double angle brackets</H3>
+<H3><a name="CPlusPlus11_double_angle_brackets"></a>7.2.13 Double angle brackets</H3>
<p>SWIG correctly parses the symbols &gt;&gt; as closing the
@@ -479,7 +481,7 @@ shift operator &gt;&gt; otherwise.</p>
std::vector&lt;std::vector&lt;int&gt;&gt; myIntTable;
</pre></div>
-<H3><a name="CPlusPlus11_Explicit_conversion_operators"></a>7.2.14 Explicit conversion operators</H3>
+<H3><a name="CPlusPlus11_explicit_conversion_operators"></a>7.2.14 Explicit conversion operators</H3>
<p>SWIG correctly parses the keyword <tt>explicit</tt> both for operators and constructors.
@@ -515,7 +517,8 @@ SWIG target languages, because all use their own facilities (eg. classes Cloneab
to achieve particular copy and compare behaviours.
</p>
-<H3><a name="CPlusPlus11_Alias_templates"></a>7.2.15 Alias templates</H3>
+<H3><a name="CPlusPlus11_alias_templates"></a>7.2.15 Alias templates</H3>
+
<p>
The following is an example of an alias template:
@@ -567,7 +570,7 @@ example.i:17: Warning 341: The 'using' keyword in type aliasing is not fully sup
typedef void (*PFD)(double); // The old style
</pre></div>
-<H3><a name="CPlusPlus11_Unrestricted_unions"></a>7.2.16 Unrestricted unions</H3>
+<H3><a name="CPlusPlus11_unrestricted_unions"></a>7.2.16 Unrestricted unions</H3>
<p>SWIG fully supports any type inside a union even if it does not
@@ -581,7 +584,7 @@ struct point {
int x_, y_;
};
-#include <new> // For placement 'new' in the constructor below
+#include &lt;new&gt; // For placement 'new' in the constructor below
union P {
int z;
double w;
@@ -593,7 +596,7 @@ union P {
} p1;
</pre></div>
-<H3><a name="CPlusPlus11_Variadic_templates"></a>7.2.17 Variadic templates</H3>
+<H3><a name="CPlusPlus11_variadic_templates"></a>7.2.17 Variadic templates</H3>
<p>SWIG supports the variadic templates syntax (inside the &lt;&gt;
@@ -628,7 +631,7 @@ const int SIZE = sizeof...(ClassName&lt;int, int&gt;);
In the above example <tt>SIZE</tt> is of course wrapped as a constant.
</p>
-<H3><a name="CPlusPlus11_New_string_literals"></a>7.2.18 New string literals</H3>
+<H3><a name="CPlusPlus11_new_string_literals"></a>7.2.18 New string literals</H3>
<p>SWIG supports unicode string constants and raw string literals.</p>
@@ -652,7 +655,7 @@ const char32_t *ii = UR"XXX(I'm a "raw UTF-32" \ string.)XXX";
<p>Note: SWIG currently incorrectly parses the odd number of double quotes
inside the string due to SWIG's C++ preprocessor.</p>
-<H3><a name="CPlusPlus11_User_defined_literals"></a>7.2.19 User-defined literals</H3>
+<H3><a name="CPlusPlus11_user_defined_literals"></a>7.2.19 User-defined literals</H3>
<p>
@@ -719,7 +722,7 @@ OutputType var2 = 1234_suffix;
OutputType var3 = 3.1416_suffix;
</pre></div>
-<H3><a name="CPlusPlus11_Thread_local_storage"></a>7.2.20 Thread-local storage</H3>
+<H3><a name="CPlusPlus11_thread_local_storage"></a>7.2.20 Thread-local storage</H3>
<p>SWIG correctly parses the <tt>thread_local</tt> keyword. For example, variable
@@ -739,30 +742,34 @@ A variable will be thread local if accessed from different threads from the targ
same way that it will be thread local if accessed from C++ code.
</p>
-<H3><a name="CPlusPlus11_Defaulting/deleting_of_standard_functions_on_C++_objects"></a>7.2.21 Defaulting/deleting of standard functions on C++ objects</H3>
+<H3><a name="CPlusPlus11_defaulted_deleted"></a>7.2.21 Explicitly defaulted functions and deleted functions</H3>
-<p>SWIG correctly parses the <tt>= delete</tt> and <tt>= default</tt>
-keywords. For example:</p>
+<p>SWIG handles explicitly defaulted functions, that is, <tt>= default</tt> added to a function declaration. Deleted definitions, which are also called deleted functions, have <tt>= delete</tt> added to the function declaration.
+For example:</p>
<div class="code"><pre>
struct NonCopyable {
NonCopyable&amp; operator=(const NonCopyable&amp;) = delete; /* Removes operator= */
- NonCopyable(const NonCopyable&amp;) = delete; /* Removed copy constructor */
- NonCopyable() = default; /* Explicitly allows the empty constructor */
- void *operator new(std::size_t) = delete; /* Removes new NonCopyable */
+ NonCopyable(const NonCopyable&amp;) = delete; /* Removed copy constructor */
+ NonCopyable() = default; /* Explicitly allows the empty constructor */
+ void *operator new(std::size_t) = delete; /* Removes new NonCopyable */
};
</pre></div>
-<p>This feature is specific to C++ only. The defaulting/deleting is currently ignored, because SWIG
-automatically produces wrappers for special constructors and operators specific to the target language.</p>
+<p>
+Wrappers for deleted functions will not be available in the target language.
+Wrappers for defaulted functions will of course be available in the target language.
+Explicitly defaulted functions have no direct effect for SWIG wrapping as the declaration is handled
+much like any other method declaration parsed by SWIG.
+</p>
-<H3><a name="CPlusPlus11_Type_long_long_int"></a>7.2.22 Type long long int</H3>
+<H3><a name="CPlusPlus11_type_long_long_int"></a>7.2.22 Type long long int</H3>
<p>SWIG correctly parses and uses the new <tt>long long</tt> type already introduced in C99 some time ago.</p>
-<H3><a name="CPlusPlus11_Static_assertions"></a>7.2.23 Static assertions</H3>
+<H3><a name="CPlusPlus11_static_assertions"></a>7.2.23 Static assertions</H3>
<p>SWIG correctly parses and calls the new <tt>static_assert</tt> function.</p>
@@ -774,7 +781,7 @@ struct Check {
};
</pre></div>
-<H3><a name="CPlusPlus11_Allow_sizeof_to_work_on_members_of_classes_without_an_explicit_object"></a>7.2.24 Allow sizeof to work on members of classes without an explicit object</H3>
+<H3><a name="CPlusPlus11_allow_sizeof_to_work_on_members_of_classes_without_an_explicit_object"></a>7.2.24 Allow sizeof to work on members of classes without an explicit object</H3>
<p>SWIG correctly calls the sizeof() on types as well as on the
@@ -794,28 +801,45 @@ const int SIZE = sizeof(A::member); // does not work with C++03. Okay with C++11
8
</pre></div>
-<H2><a name="CPlusPlus11_Standard_library_changes"></a>7.3 Standard library changes</H2>
+<H3><a name="CPlusPlus11_noexcept"></a>7.2.25 Exception specifications and noexcept</H3>
+
+
+<p>
+C++11 added in the noexcept specification to exception specifications to indicate that a function simply may or may not throw an exception, without actually naming any exception.
+SWIG understands these, although there isn't any useful way that this information can be taken advantage of by target languages,
+so it is as good as ignored during the wrapping process.
+Below are some examples of noexcept in function declarations:
+</p>
+
+<div class="code"><pre>
+static void noex1() noexcept;
+int noex2(int) noexcept(true);
+int noex3(int, bool) noexcept(false);
+</pre></div>
+
+
+<H2><a name="CPlusPlus11_standard_library_changes"></a>7.3 Standard library changes</H2>
-<H3><a name="CPlusPlus11_Threading_facilities"></a>7.3.1 Threading facilities</H3>
+<H3><a name="CPlusPlus11_threading_facilities"></a>7.3.1 Threading facilities</H3>
<p>SWIG does not currently wrap or use any of the new threading
classes introduced (thread, mutex, locks, condition variables, task). The main reason is that
SWIG target languages offer their own threading facilities that do not rely on C++.</p>
-<H3><a name="CPlusPlus11_Tuple_types"></a>7.3.2 Tuple types and hash tables</H3>
+<H3><a name="CPlusPlus11_tuple_types"></a>7.3.2 Tuple types and hash tables</H3>
<p>SWIG does not wrap the new tuple types and the unordered_ container classes yet. Variadic template support is working so it is possible to
include the tuple header file; it is parsed without any problems.</p>
-<H3><a name="CPlusPlus11_Regular_expressions"></a>7.3.3 Regular expressions</H3>
+<H3><a name="CPlusPlus11_regular_expressions"></a>7.3.3 Regular expressions</H3>
<p>SWIG does not wrap the new C++11 regular expressions classes, because the SWIG target languages use their own facilities for this.</p>
-<H3><a name="CPlusPlus11_General_purpose_smart_pointers"></a>7.3.4 General-purpose smart pointers</H3>
+<H3><a name="CPlusPlus11_general_purpose_smart_pointers"></a>7.3.4 General-purpose smart pointers</H3>
<p>
@@ -823,12 +847,12 @@ SWIG provides special smart pointer handling for <tt>std::tr1::shared_ptr</tt> i
There is no special smart pointer handling available for <tt>std::weak_ptr</tt> and <tt>std::unique_ptr</tt>.
</p>
-<H3><a name="CPlusPlus11_Extensible_random_number_facility"></a>7.3.5 Extensible random number facility</H3>
+<H3><a name="CPlusPlus11_extensible_random_number_facility"></a>7.3.5 Extensible random number facility</H3>
<p>This feature extends and standardizes the standard library only and does not effect the C++ language and SWIG.</p>
-<H3><a name="CPlusPlus11_Wrapper_reference"></a>7.3.6 Wrapper reference</H3>
+<H3><a name="CPlusPlus11_wrapper_reference"></a>7.3.6 Wrapper reference</H3>
<p>The new ref and cref classes are used to instantiate a parameter as a reference of a template function. For example:</p>
@@ -853,7 +877,7 @@ int main() {
<p>The ref and cref classes are not wrapped by SWIG because the SWIG target languages do not support referencing.</p>
-<H3><a name="CPlusPlus11_Polymorphous_wrappers_for_function_objects"></a>7.3.7 Polymorphous wrappers for function objects</H3>
+<H3><a name="CPlusPlus11_polymorphous_wrappers_for_function_objects"></a>7.3.7 Polymorphous wrappers for function objects</H3>
<p>
@@ -879,12 +903,12 @@ Example of supported usage of the plain functor from Python is shown below.
It does not involve <tt>std::function</tt>.
</p>
-<div class="targetlang">
+<div class="targetlang"><pre>
t = Test()
b = t(1,2) # invoke C++ function object
</pre></div>
-<H3><a name="CPlusPlus11_Type_traits_for_metaprogramming"></a>7.3.8 Type traits for metaprogramming</H3>
+<H3><a name="CPlusPlus11_type_traits_for_metaprogramming"></a>7.3.8 Type traits for metaprogramming</H3>
<p>The new C++ metaprogramming is useful at compile time and is aimed specifically for C++ development:</p>
@@ -909,7 +933,7 @@ template&lt; class T1, class T2 &gt; int elaborate( T1 A, T2 B ) {
<p>SWIG correctly parses the template specialization, template types and values inside the &lt;&gt; block and the new helper functions: is_convertible, is_integral, is_const etc.
However, SWIG still explicitly requires concrete types when using the <tt>%template</tt> directive, so the C++ metaprogramming features are not really of interest at runtime in the target languages.</p>
-<H3><a name="CPlusPlus11_Uniform_method_for_computing_return_type_of_function_objects"></a>7.3.9 Uniform method for computing return type of function objects</H3>
+<H3><a name="CPlusPlus11_uniform_method_for_computing_return_type_of_function_objects"></a>7.3.9 Uniform method for computing return type of function objects</H3>
<p>SWIG does not wrap the new result_of class introduced in the &lt;functional&gt; header and map the result_of::type to the concrete type yet. For example:</p>
@@ -938,5 +962,6 @@ typename std::result_of&lt;Fun(Arg)&gt;::type test_result_impl(Fun fun, Arg arg)
</pre></div>
<p>Instead, please use <tt>decltype()</tt> where possible for now.</p>
+
</body>
</html>
diff --git a/Examples/test-suite/c_delete.i b/Examples/test-suite/c_delete.i
new file mode 100644
index 000000000..632340629
--- /dev/null
+++ b/Examples/test-suite/c_delete.i
@@ -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
diff --git a/Examples/test-suite/c_delete_function.i b/Examples/test-suite/c_delete_function.i
new file mode 100644
index 000000000..3739ceadc
--- /dev/null
+++ b/Examples/test-suite/c_delete_function.i
@@ -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
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index e25d36715..e5127fd0c 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -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 \
diff --git a/Examples/test-suite/cpp11_default_delete.i b/Examples/test-suite/cpp11_default_delete.i
index be4cc6cc9..79c02cddc 100644
--- a/Examples/test-suite/cpp11_default_delete.i
+++ b/Examples/test-suite/cpp11_default_delete.i
@@ -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;
};
+
%}
diff --git a/Examples/test-suite/cpp11_noexcept.i b/Examples/test-suite/cpp11_noexcept.i
new file mode 100644
index 000000000..6fed5b8df
--- /dev/null
+++ b/Examples/test-suite/cpp11_noexcept.i
@@ -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;
+};
+
+%}
+
diff --git a/Lib/csharp/csharpkw.swg b/Lib/csharp/csharpkw.swg
index 9a6d979f1..43ca5993b 100644
--- a/Lib/csharp/csharpkw.swg
+++ b/Lib/csharp/csharpkw.swg
@@ -4,6 +4,8 @@
/* Warnings for C# keywords */
#define CSHARPKW(x) %keywordwarn("'" `x` "' is a C# keyword, renaming to '_" `x` "'",rename="_%s") `x`
+#define CSHARPCLASSKW(x) %keywordwarn("'" `x` "' is a special method name used in the C# wrapper classes, class renamed to '_" `x` "'",%$isclass,rename="_%s") `x`
+
/*
from
http://www.jaggersoft.com/csharp_grammar.html#1.7%20Keywords
@@ -88,6 +90,7 @@ CSHARPKW(void);
CSHARPKW(volatile);
CSHARPKW(while);
+CSHARPCLASSKW(delete);
#undef CSHARPKW
diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c
index e91dfb3d3..c04ce4688 100644
--- a/Source/CParse/cscanner.c
+++ b/Source/CParse/cscanner.c
@@ -705,6 +705,8 @@ int yylex(void) {
}
if (strcmp(yytext, "throw") == 0)
return (THROW);
+ if (strcmp(yytext, "noexcept") == 0)
+ return (NOEXCEPT);
if (strcmp(yytext, "try") == 0)
return (yylex());
if (strcmp(yytext, "catch") == 0)
@@ -728,6 +730,9 @@ int yylex(void) {
if (strcmp(yytext, "delete") == 0) {
return (DELETE_KW);
}
+ if (strcmp(yytext, "default") == 0) {
+ return (DEFAULT);
+ }
if (strcmp(yytext, "using") == 0) {
return (USING);
}
diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
index ce0c91c43..caac88e4d 100644
--- a/Source/CParse/parser.y
+++ b/Source/CParse/parser.y
@@ -447,6 +447,14 @@ static void add_symbols(Node *n) {
n = nextSibling(n);
continue;
}
+ if (cparse_cplusplus) {
+ String *value = Getattr(n, "value");
+ if (value && Strcmp(value, "delete") == 0) {
+ /* C++11 deleted definition / deleted function */
+ SetFlag(n,"deleted");
+ SetFlag(n,"feature:ignore");
+ }
+ }
if (only_csymbol || GetFlag(n,"feature:ignore")) {
/* Only add to C symbol table and continue */
Swig_symbol_add(0, n);
@@ -1661,6 +1669,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
String *bitfield;
Parm *throws;
String *throwf;
+ String *nexcept;
} dtype;
struct {
char *type;
@@ -1675,6 +1684,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
short have_parms;
ParmList *throws;
String *throwf;
+ String *nexcept;
} decl;
Parm *tparms;
struct {
@@ -1708,14 +1718,14 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
%token ILLEGAL CONSTANT
%token NAME RENAME NAMEWARN EXTEND PRAGMA FEATURE VARARGS
%token ENUM
-%token CLASS TYPENAME PRIVATE PUBLIC PROTECTED COLON STATIC VIRTUAL FRIEND THROW CATCH EXPLICIT AUTO
+%token CLASS TYPENAME PRIVATE PUBLIC PROTECTED COLON STATIC VIRTUAL FRIEND THROW CATCH EXPLICIT AUTO NOEXCEPT
%token STATIC_ASSERT CONSTEXPR THREAD_LOCAL DECLTYPE /* C++11 keywords */
%token USING
%token <node> NAMESPACE
%token NATIVE INLINE
%token TYPEMAP EXCEPT ECHO APPLY CLEAR SWIGTEMPLATE FRAGMENT
%token WARN
-%token LESSTHAN GREATERTHAN DELETE_KW
+%token LESSTHAN GREATERTHAN DELETE_KW DEFAULT
%token LESSTHANOREQUALTO GREATERTHANOREQUALTO EQUALTO NOTEQUALTO
%token ARROW
%token QUESTIONMARK
@@ -1763,7 +1773,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
%type <node> kwargs options;
/* Misc */
-%type <dtype> initializer cpp_const ;
+%type <dtype> initializer cpp_const exception_specification;
%type <id> storage_class;
%type <pl> parms ptail rawparms varargs_parms ;
%type <pl> templateparameters templateparameterstail;
@@ -1775,7 +1785,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
%type <str> ellipsis variadic;
%type <type> type rawtype type_right anon_bitfield_type decltype ;
%type <bases> base_list inherit raw_inherit;
-%type <dtype> definetype def_args etype;
+%type <dtype> definetype def_args etype default_delete deleted_definition explicit_default;
%type <dtype> expr exprnum exprcompound valexpr;
%type <id> ename ;
%type <id> template_decl;
@@ -3226,6 +3236,7 @@ c_decl : storage_class type declarator initializer c_decl_tail {
Setattr($$,"value",$4.val);
Setattr($$,"throws",$4.throws);
Setattr($$,"throw",$4.throwf);
+ Setattr($$,"noexcept",$4.nexcept);
if (!$5) {
if (Len(scanner_ccode)) {
String *code = Copy(scanner_ccode);
@@ -3285,6 +3296,7 @@ c_decl : storage_class type declarator initializer c_decl_tail {
Setattr($$,"value",$6.val);
Setattr($$,"throws",$6.throws);
Setattr($$,"throw",$6.throwf);
+ Setattr($$,"noexcept",$6.nexcept);
if (!$7) {
if (Len(scanner_ccode)) {
String *code = Copy(scanner_ccode);
@@ -3344,6 +3356,7 @@ c_decl_tail : SEMI {
Setattr($$,"value",$3.val);
Setattr($$,"throws",$3.throws);
Setattr($$,"throw",$3.throwf);
+ Setattr($$,"noexcept",$3.nexcept);
if ($3.bitfield) {
Setattr($$,"bitfield", $3.bitfield);
}
@@ -3368,24 +3381,28 @@ initializer : def_args {
$$.qualifier = 0;
$$.throws = 0;
$$.throwf = 0;
+ $$.nexcept = 0;
}
| type_qualifier def_args {
$$ = $2;
$$.qualifier = $1;
$$.throws = 0;
$$.throwf = 0;
+ $$.nexcept = 0;
}
- | THROW LPAREN parms RPAREN def_args {
- $$ = $5;
+ | exception_specification def_args {
+ $$ = $2;
$$.qualifier = 0;
- $$.throws = $3;
- $$.throwf = NewString("1");
+ $$.throws = $1.throws;
+ $$.throwf = $1.throwf;
+ $$.nexcept = $1.nexcept;
}
- | type_qualifier THROW LPAREN parms RPAREN def_args {
- $$ = $6;
+ | type_qualifier exception_specification def_args {
+ $$ = $3;
$$.qualifier = $1;
- $$.throws = $4;
- $$.throwf = NewString("1");
+ $$.throws = $2.throws;
+ $$.throwf = $2.throwf;
+ $$.nexcept = $2.nexcept;
}
;
@@ -3661,6 +3678,7 @@ c_constructor_decl : storage_class type LPAREN parms RPAREN ctor_end {
}
Setattr($$,"throws",$6.throws);
Setattr($$,"throw",$6.throwf);
+ Setattr($$,"noexcept",$6.nexcept);
err = 0;
}
}
@@ -4690,12 +4708,15 @@ cpp_constructor_decl : storage_class type LPAREN parms RPAREN ctor_end {
Setattr($$,"decl",decl);
Setattr($$,"throws",$6.throws);
Setattr($$,"throw",$6.throwf);
+ Setattr($$,"noexcept",$6.nexcept);
if (Len(scanner_ccode)) {
String *code = Copy(scanner_ccode);
Setattr($$,"code",code);
Delete(code);
}
SetFlag($$,"feature:new");
+ if ($6.defarg)
+ Setattr($$,"value",$6.defarg);
} else {
$$ = 0;
}
@@ -4723,6 +4744,9 @@ cpp_destructor_decl : NOT idtemplate LPAREN parms RPAREN cpp_end {
}
Setattr($$,"throws",$6.throws);
Setattr($$,"throw",$6.throwf);
+ Setattr($$,"noexcept",$6.nexcept);
+ if ($6.val)
+ Setattr($$,"value",$6.val);
add_symbols($$);
}
@@ -4738,9 +4762,9 @@ cpp_destructor_decl : NOT idtemplate LPAREN parms RPAREN cpp_end {
Delete(name);
Setattr($$,"throws",$7.throws);
Setattr($$,"throw",$7.throwf);
- if ($7.val) {
- Setattr($$,"value","0");
- }
+ Setattr($$,"noexcept",$7.nexcept);
+ if ($7.val)
+ Setattr($$,"value",$7.val);
if (Len(scanner_ccode)) {
String *code = Copy(scanner_ccode);
Setattr($$,"code",code);
@@ -4982,13 +5006,24 @@ cpp_swig_directive: pragma_directive { $$ = $1; }
cpp_end : cpp_const SEMI {
Clear(scanner_ccode);
+ $$.val = 0;
$$.throws = $1.throws;
$$.throwf = $1.throwf;
+ $$.nexcept = $1.nexcept;
+ }
+ | cpp_const EQUAL default_delete SEMI {
+ Clear(scanner_ccode);
+ $$.val = $3.val;
+ $$.throws = $1.throws;
+ $$.throwf = $1.throwf;
+ $$.nexcept = $1.nexcept;
}
| cpp_const LBRACE {
skip_balanced('{','}');
+ $$.val = 0;
$$.throws = $1.throws;
$$.throwf = $1.throwf;
+ $$.nexcept = $1.nexcept;
}
;
@@ -4999,6 +5034,7 @@ cpp_vend : cpp_const SEMI {
$$.bitfield = 0;
$$.throws = $1.throws;
$$.throwf = $1.throwf;
+ $$.nexcept = $1.nexcept;
}
| cpp_const EQUAL definetype SEMI {
Clear(scanner_ccode);
@@ -5007,6 +5043,7 @@ cpp_vend : cpp_const SEMI {
$$.bitfield = 0;
$$.throws = $1.throws;
$$.throwf = $1.throwf;
+ $$.nexcept = $1.nexcept;
}
| cpp_const LBRACE {
skip_balanced('{','}');
@@ -5015,6 +5052,7 @@ cpp_vend : cpp_const SEMI {
$$.bitfield = 0;
$$.throws = $1.throws;
$$.throwf = $1.throwf;
+ $$.nexcept = $1.nexcept;
}
;
@@ -5066,6 +5104,7 @@ storage_class : EXTERN { $$ = "extern"; }
| FRIEND { $$ = "friend"; }
| EXPLICIT { $$ = "explicit"; }
| CONSTEXPR { $$ = "constexpr"; }
+ | STATIC CONSTEXPR { $$ = "static constexpr"; }
| THREAD_LOCAL { $$ = "thread_local"; }
| THREAD_LOCAL STATIC { $$ = "static thread_local"; }
| STATIC THREAD_LOCAL { $$ = "static thread_local"; }
@@ -5203,6 +5242,7 @@ def_args : EQUAL definetype {
$$.bitfield = 0;
$$.throws = 0;
$$.throwf = 0;
+ $$.nexcept = 0;
}
}
| EQUAL definetype LBRACKET expr RBRACKET {
@@ -5215,6 +5255,7 @@ def_args : EQUAL definetype {
$$.bitfield = 0;
$$.throws = 0;
$$.throwf = 0;
+ $$.nexcept = 0;
} else {
$$.val = NewStringf("%s[%s]",$2.val,$4.val);
}
@@ -5227,6 +5268,7 @@ def_args : EQUAL definetype {
$$.bitfield = 0;
$$.throws = 0;
$$.throwf = 0;
+ $$.nexcept = 0;
}
| COLON expr {
$$.val = 0;
@@ -5235,6 +5277,7 @@ def_args : EQUAL definetype {
$$.bitfield = $2.val;
$$.throws = 0;
$$.throwf = 0;
+ $$.nexcept = 0;
}
| empty {
$$.val = 0;
@@ -5243,6 +5286,7 @@ def_args : EQUAL definetype {
$$.bitfield = 0;
$$.throws = 0;
$$.throwf = 0;
+ $$.nexcept = 0;
}
;
@@ -6143,11 +6187,16 @@ definetype : { /* scanner_check_typedef(); */ } expr {
} else if ($$.type != T_CHAR && $$.type != T_WSTRING && $$.type != T_WCHAR) {
$$.rawval = 0;
}
+ $$.qualifier = 0;
$$.bitfield = 0;
$$.throws = 0;
$$.throwf = 0;
+ $$.nexcept = 0;
scanner_ignore_typedef();
}
+ | default_delete {
+ $$ = $1;
+ }
/*
| string {
$$.val = NewString($1);
@@ -6156,10 +6205,45 @@ definetype : { /* scanner_check_typedef(); */ } expr {
$$.bitfield = 0;
$$.throws = 0;
$$.throwf = 0;
+ $$.nexcept = 0;
}
*/
;
+default_delete : deleted_definition {
+ $$ = $1;
+ }
+ | explicit_default {
+ $$ = $1;
+ }
+ ;
+
+/* For C++ deleted definition '= delete' */
+deleted_definition : DELETE_KW {
+ $$.val = NewString("delete");
+ $$.rawval = 0;
+ $$.type = T_STRING;
+ $$.qualifier = 0;
+ $$.bitfield = 0;
+ $$.throws = 0;
+ $$.throwf = 0;
+ $$.nexcept = 0;
+ }
+ ;
+
+/* For C++ explicitly defaulted functions '= default' */
+explicit_default : DEFAULT {
+ $$.val = NewString("default");
+ $$.rawval = 0;
+ $$.type = T_STRING;
+ $$.qualifier = 0;
+ $$.bitfield = 0;
+ $$.throws = 0;
+ $$.throwf = 0;
+ $$.nexcept = 0;
+ }
+ ;
+
/* Some stuff for handling enums */
ename : ID { $$ = $1; }
@@ -6276,6 +6360,7 @@ valexpr : exprnum { $$ = $1; }
$$.bitfield = 0;
$$.throws = 0;
$$.throwf = 0;
+ $$.nexcept = 0;
}
| WCHARCONST {
$$.val = NewString($1);
@@ -6288,6 +6373,7 @@ valexpr : exprnum { $$ = $1; }
$$.bitfield = 0;
$$.throws = 0;
$$.throwf = 0;
+ $$.nexcept = 0;
}
/* grouping */
@@ -6613,25 +6699,43 @@ opt_virtual : VIRTUAL
| empty
;
+exception_specification : THROW LPAREN parms RPAREN {
+ $$.throws = $3;
+ $$.throwf = NewString("1");
+ $$.nexcept = 0;
+ }
+ | NOEXCEPT {
+ $$.throws = 0;
+ $$.throwf = 0;
+ $$.nexcept = NewString("true");
+ }
+
+ | NOEXCEPT LPAREN expr RPAREN {
+ $$.throws = 0;
+ $$.throwf = 0;
+ $$.nexcept = $3.val;
+ }
+ ;
+
cpp_const : type_qualifier {
- $$.qualifier = $1;
$$.throws = 0;
$$.throwf = 0;
+ $$.nexcept = 0;
+ $$.qualifier = $1;
}
- | THROW LPAREN parms RPAREN {
+ | exception_specification {
+ $$ = $1;
$$.qualifier = 0;
- $$.throws = $3;
- $$.throwf = NewString("1");
}
- | type_qualifier THROW LPAREN parms RPAREN {
+ | type_qualifier exception_specification {
+ $$ = $2;
$$.qualifier = $1;
- $$.throws = $4;
- $$.throwf = NewString("1");
}
| empty {
- $$.qualifier = 0;
$$.throws = 0;
$$.throwf = 0;
+ $$.nexcept = 0;
+ $$.qualifier = 0;
}
;
@@ -6641,6 +6745,7 @@ ctor_end : cpp_const ctor_initializer SEMI {
$$.defarg = 0;
$$.throws = $1.throws;
$$.throwf = $1.throwf;
+ $$.nexcept = $1.nexcept;
}
| cpp_const ctor_initializer LBRACE {
skip_balanced('{','}');
@@ -6648,6 +6753,7 @@ ctor_end : cpp_const ctor_initializer SEMI {
$$.defarg = 0;
$$.throws = $1.throws;
$$.throwf = $1.throwf;
+ $$.nexcept = $1.nexcept;
}
| LPAREN parms RPAREN SEMI {
Clear(scanner_ccode);
@@ -6656,6 +6762,7 @@ ctor_end : cpp_const ctor_initializer SEMI {
$$.defarg = 0;
$$.throws = 0;
$$.throwf = 0;
+ $$.nexcept = 0;
}
| LPAREN parms RPAREN LBRACE {
skip_balanced('{','}');
@@ -6664,12 +6771,21 @@ ctor_end : cpp_const ctor_initializer SEMI {
$$.defarg = 0;
$$.throws = 0;
$$.throwf = 0;
+ $$.nexcept = 0;
}
| EQUAL definetype SEMI {
$$.have_parms = 0;
$$.defarg = $2.val;
$$.throws = 0;
$$.throwf = 0;
+ $$.nexcept = 0;
+ }
+ | exception_specification EQUAL default_delete SEMI {
+ $$.have_parms = 0;
+ $$.defarg = $3.val;
+ $$.throws = $1.throws;
+ $$.throwf = $1.throwf;
+ $$.nexcept = $1.nexcept;
}
;
@@ -6711,6 +6827,7 @@ template_decl : LESSTHAN valparms GREATERTHAN {
;
idstring : ID { $$ = $1; }
+ | default_delete { $$ = $1.val; }
| string { $$ = $1; }
;
diff --git a/Source/Modules/allocate.cxx b/Source/Modules/allocate.cxx
index dee044bf3..b7daae59c 100644
--- a/Source/Modules/allocate.cxx
+++ b/Source/Modules/allocate.cxx
@@ -659,7 +659,7 @@ Allocate():
}
if (!Getattr(n, "allocate:has_destructor")) {
- /* No destructor was defined. We need to check a few things here too */
+ /* No destructor was defined */
List *bases = Getattr(n, "allbases");
int allows_destruct = 1;
@@ -676,13 +676,13 @@ Allocate():
}
if (!Getattr(n, "allocate:has_assign")) {
- /* No destructor was defined. We need to check a few things here too */
+ /* No assignment operator was defined */
List *bases = Getattr(n, "allbases");
int allows_assign = 1;
for (int i = 0; i < Len(bases); i++) {
Node *n = Getitem(bases, i);
- /* If base class does not allow default destructor, we don't allow it either */
+ /* If base class does not allow assignment, we don't allow it either */
if (Getattr(n, "allocate:has_assign")) {
allows_assign = !Getattr(n, "allocate:noassign");
}
@@ -693,13 +693,13 @@ Allocate():
}
if (!Getattr(n, "allocate:has_new")) {
- /* No destructor was defined. We need to check a few things here too */
+ /* No new operator was defined */
List *bases = Getattr(n, "allbases");
int allows_new = 1;
for (int i = 0; i < Len(bases); i++) {
Node *n = Getitem(bases, i);
- /* If base class does not allow default destructor, we don't allow it either */
+ /* If base class does not allow new operator, we don't allow it either */
if (Getattr(n, "allocate:has_new")) {
allows_new = !Getattr(n, "allocate:nonew");
}
@@ -779,18 +779,26 @@ Allocate():
if (cplus_mode != PUBLIC) {
if (Strcmp(name, "operator =") == 0) {
/* Look for a private assignment operator */
- Setattr(inclass, "allocate:has_assign", "1");
+ if (!GetFlag(n, "deleted"))
+ Setattr(inclass, "allocate:has_assign", "1");
Setattr(inclass, "allocate:noassign", "1");
} else if (Strcmp(name, "operator new") == 0) {
/* Look for a private new operator */
- Setattr(inclass, "allocate:has_new", "1");
+ if (!GetFlag(n, "deleted"))
+ Setattr(inclass, "allocate:has_new", "1");
Setattr(inclass, "allocate:nonew", "1");
}
} else {
if (Strcmp(name, "operator =") == 0) {
- Setattr(inclass, "allocate:has_assign", "1");
+ if (!GetFlag(n, "deleted"))
+ Setattr(inclass, "allocate:has_assign", "1");
+ else
+ Setattr(inclass, "allocate:noassign", "1");
} else if (Strcmp(name, "operator new") == 0) {
- Setattr(inclass, "allocate:has_new", "1");
+ if (!GetFlag(n, "deleted"))
+ Setattr(inclass, "allocate:has_new", "1");
+ else
+ Setattr(inclass, "allocate:nonew", "1");
}
/* Look for smart pointer operator */
if ((Strcmp(name, "operator ->") == 0) && (!GetFlag(n, "feature:ignore"))) {