aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2012-09-21 18:04:15 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2012-09-21 18:04:15 +0000
commitdbdbdd94aa44da8e3213c08cd252549578db17a4 (patch)
treee9bdd286f34350c3dbc2c7ea0b0daa655bd996a7
parent171435f9895e59c66c7fc26af695f87302dd6e73 (diff)
downloadswig-dbdbdd94aa44da8e3213c08cd252549578db17a4.tar.gz
Some updates to c++11 warning messages and update docs on alias templates
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@13847 626c5289-ae23-0410-ae9c-e8d60b6d4f22
-rw-r--r--Doc/Manual/Cpp0x.html46
-rw-r--r--Examples/test-suite/common.mk2
-rw-r--r--Examples/test-suite/cpp0x_template_typedefs.i3
-rw-r--r--Source/CParse/parser.y6
4 files changed, 47 insertions, 10 deletions
diff --git a/Doc/Manual/Cpp0x.html b/Doc/Manual/Cpp0x.html
index c93121200..ef64fecc1 100644
--- a/Doc/Manual/Cpp0x.html
+++ b/Doc/Manual/Cpp0x.html
@@ -27,7 +27,7 @@
<li><a href="#Cpp0x_Strongly_typed_enumerations">Strongly typed enumerations</a>
<li><a href="#Cpp0x_Double_angle_brackets">Double angle brackets</a>
<li><a href="#Cpp0x_Explicit_conversion_operators">Explicit conversion operators</a>
-<li><a href="#Cpp0x_Template_typedefs">Template typedefs</a>
+<li><a href="#Cpp0x_Alias_templates">Alias templates</a>
<li><a href="#Cpp0x_Unrestricted_unions">Unrestricted unions</a>
<li><a href="#Cpp0x_Variadic_templates">Variadic templates</a>
<li><a href="#Cpp0x_New_string_literals">New string literals</a>
@@ -382,17 +382,53 @@ SWIG target languages, because all use their own facilities (eg. classes Cloneab
to achieve particular copy and compare behaviours.
</p>
-<H3><a name="Cpp0x_Template_typedefs"></a>7.2.15 Template typedefs</H3>
+<H3><a name="Cpp0x_Alias_templates"></a>7.2.15 Alias templates</H3>
+<p>
+The following is an example of an alias template:
+
+<div class="code"><pre>
+template&lt; typename T1, typename T2, int &gt;
+class SomeType {
+ T1 a;
+ T2 b;
+ int c;
+};
+
+template&lt; typename T2 &gt;
+using TypedefName = SomeType&lt;char*, T2, 5&gt;;
+</pre></div>
-<p>SWIG currently parses the new <tt>using name =</tt> syntax, but
-ignores the definition:</p>
+<p>
+These are partially supported as SWIG will parse these and identify them, however, they are ignored as they are not added to the type system. A warning such as the following is issued:
+</p>
+
+<div class="shell">
+<pre>
+example.i:13: Warning 342: The 'using' keyword in template aliasing is not fully supported yet.
+</pre>
+</div>
+
+<p>
+Similarly for non-template type aliasing:
+</p>
<div class="code"><pre>
using PFD = void (*)(double); // New introduced syntax
</pre></div>
-<p>You should still define the typedefs using the old syntax:</p>
+<p>
+A warning will be issued:
+</p>
+
+<div class="shell">
+<pre>
+example.i:17: Warning 341: The 'using' keyword in type aliasing is not fully supported yet.
+</pre>
+</div>
+
+
+<p>The equivalent old style typedefs can be used as a workaround:</p>
<div class="code"><pre>
typedef void (*PFD)(double); // The old style
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index b496fe3c4..3e5b7789c 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -454,7 +454,7 @@ CPP0X_TEST_CASES = \
# cpp0x_constructors \ # not supported by any compiler yet
# cpp0x_hash_tables \ # not fully implemented yet
# cpp0x_lambda_functions \ # not supported by GCC or MSVC yet
-# cpp0x_template_typedefs \ # not supported by any compiler yet
+# cpp0x_template_typedefs \ # not supported by any compiler yet (now in gcc-4.7)
# cpp0x_thread_local \ # not supported by any compiler yet
# cpp0x_unrestricted_unions \ # not supported by any compiler yet (now in gcc-4.6)
diff --git a/Examples/test-suite/cpp0x_template_typedefs.i b/Examples/test-suite/cpp0x_template_typedefs.i
index 877539bfb..bd7e2b220 100644
--- a/Examples/test-suite/cpp0x_template_typedefs.i
+++ b/Examples/test-suite/cpp0x_template_typedefs.i
@@ -1,4 +1,4 @@
-/* This testcase checks whether SWIG correctly parses the template aliasing. */
+/* This testcase checks whether SWIG correctly parses alias templates. */
%module cpp0x_template_typedefs
%inline %{
@@ -12,6 +12,7 @@ class SomeType {
template< typename T2 >
using TypedefName = SomeType<char*, T2, 5>;
+// type aliasing
typedef void (*PFD)(double); // Old style
using PF = void (*)(double); // New introduced syntax
%}
diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
index effe11ccc..f601aab9f 100644
--- a/Source/CParse/parser.y
+++ b/Source/CParse/parser.y
@@ -3098,9 +3098,9 @@ c_declaration : c_decl {
appendChild($$,firstChild($5));
}
}
- | c_lambda_decl { Swig_warning(WARN_CPP11_LAMBDA, cparse_file, cparse_line,"SWIG doesn't produce wrapper code for lambda expressions and closures yet.\n"); $$ = $1; }
- | USING idcolon EQUAL { skip_decl(); Swig_warning(WARN_CPP11_ALIAS_DECLARATION, cparse_file, cparse_line,"SWIG doesn't support the 'using' keyword in type aliasing yet.\n"); $$ = 0; }
- | TEMPLATE LESSTHAN template_parms GREATERTHAN USING idcolon EQUAL { skip_decl(); Swig_warning(WARN_CPP11_ALIAS_TEMPLATE, cparse_file, cparse_line,"SWIG doesn't support the 'using' keyword in template aliasing yet.\n"); $$ = 0; }
+ | c_lambda_decl { Swig_warning(WARN_CPP11_LAMBDA, cparse_file, cparse_line,"Lambda expressions and closures are not fully supported yet.\n"); $$ = $1; }
+ | USING idcolon EQUAL { skip_decl(); Swig_warning(WARN_CPP11_ALIAS_DECLARATION, cparse_file, cparse_line,"The 'using' keyword in type aliasing is not fully supported yet.\n"); $$ = 0; }
+ | TEMPLATE LESSTHAN template_parms GREATERTHAN USING idcolon EQUAL { skip_decl(); Swig_warning(WARN_CPP11_ALIAS_TEMPLATE, cparse_file, cparse_line,"The 'using' keyword in template aliasing is not fully supported yet.\n"); $$ = 0; }
;
/* ------------------------------------------------------------