From dbdbdd94aa44da8e3213c08cd252549578db17a4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 21 Sep 2012 18:04:15 +0000 Subject: [PATCH] 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 --- Doc/Manual/Cpp0x.html | 46 +++++++++++++++++-- Examples/test-suite/common.mk | 2 +- Examples/test-suite/cpp0x_template_typedefs.i | 3 +- Source/CParse/parser.y | 6 +-- 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 @@
  • Strongly typed enumerations
  • Double angle brackets
  • Explicit conversion operators -
  • Template typedefs +
  • Alias templates
  • Unrestricted unions
  • Variadic templates
  • New string literals @@ -382,17 +382,53 @@ SWIG target languages, because all use their own facilities (eg. classes Cloneab to achieve particular copy and compare behaviours.

    -

    7.2.15 Template typedefs

    +

    7.2.15 Alias templates

    +

    +The following is an example of an alias template: -

    SWIG currently parses the new using name = syntax, but -ignores the definition:

    +
    +template< typename T1, typename T2, int >
    +class SomeType {
    +  T1 a;
    +  T2 b;
    +  int c;
    +};
    +
    +template< typename T2 >
    +using TypedefName = SomeType<char*, T2, 5>;
    +
    + +

    +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: +

    + +
    +
    +example.i:13: Warning 342: The 'using' keyword in template aliasing is not fully supported yet.
    +
    +
    + +

    +Similarly for non-template type aliasing: +

     using PFD = void (*)(double); // New introduced syntax
     
    -

    You should still define the typedefs using the old syntax:

    +

    +A warning will be issued: +

    + +
    +
    +example.i:17: Warning 341: The 'using' keyword in type aliasing is not fully supported yet.
    +
    +
    + + +

    The equivalent old style typedefs can be used as a workaround:

     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;
     
    +// 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; }
                     ;
     
     /* ------------------------------------------------------------