Skip to content

Commit

Permalink
C++11 alias templates seg fault fix
Browse files Browse the repository at this point in the history
Segfault fix when using alias templates, reported by Pierre-Henri Wuillemin
  • Loading branch information
wsfulton committed Dec 3, 2013
1 parent 6624f66 commit b175df4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 9 additions & 0 deletions Examples/test-suite/cpp11_template_typedefs.i
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
%module cpp11_template_typedefs

%warnfilter(SWIGWARN_CPP11_ALIAS_TEMPLATE) TypedefName;
%warnfilter(SWIGWARN_CPP11_ALIAS_TEMPLATE) MyIntKeyClass;
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) PF;

%inline %{
Expand All @@ -19,5 +20,13 @@ using TypedefName = SomeType<char*, T2, 5>;
// type aliasing
typedef void (*PFD)(double); // Old style
using PF = void (*)(double); // New introduced syntax


// use of template aliasing
template<typename Key,typename Val>
class MyCPP11Class {
};
template<typename VAL> using MyIntKeyClass = MyCPP11Class<int,VAL>;
MyIntKeyClass<char> intchar;
%}

5 changes: 2 additions & 3 deletions Source/CParse/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -3208,16 +3208,15 @@ c_declaration : c_decl {

$$ = 0; /* TODO - ignored for now */
}
| TEMPLATE LESSTHAN template_parms GREATERTHAN USING idcolon EQUAL {
| TEMPLATE LESSTHAN template_parms GREATERTHAN USING idcolon EQUAL ID {
skip_decl();
$$ = new_node("using");
Setattr($$,"uname",$8);
Setattr($$,"name",$6);
add_symbols($$);
SWIG_WARN_NODE_BEGIN($$);
Swig_warning(WARN_CPP11_ALIAS_TEMPLATE, cparse_file, cparse_line, "The 'using' keyword in template aliasing is not fully supported yet.\n");
SWIG_WARN_NODE_END($$);

$$ = 0; /* TODO - ignored for now */
}
;

Expand Down

0 comments on commit b175df4

Please sign in to comment.