diff --git a/CHANGES.current b/CHANGES.current index adb4053d7..53c1b73cb 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.2.0 (in progress) =========================== +2022-12-23: wsfulton + #1863 Fix syntax error parsing variadic template parameter pack arguments that + are function pointers. + 2022-12-22: wsfulton Complete support for C++11 variadic templates. Support was previously limited to just one template parameter. Now zero or more template parameters are supported. diff --git a/Examples/test-suite/cpp11_variadic_templates.i b/Examples/test-suite/cpp11_variadic_templates.i index 9ea11368e..bb370cebf 100644 --- a/Examples/test-suite/cpp11_variadic_templates.i +++ b/Examples/test-suite/cpp11_variadic_templates.i @@ -143,15 +143,38 @@ public: %inline %{ template struct VariadicParms { public: + void ParmsVal(V... vparms_v) {} void ParmsPtr(V*... vparms_p) {} void ParmsPtrRef(V*&... vparms_pr) {} void ParmsPtrRValueRef(V*&&... vparms_rvr) {} - void ParmsVal(V... vparms_v) {} void ParmsRef(V&... vparms_r) {} + void ParmsRValueRef(V&&... vparms_r) {} void ParmsConstRef(const V&... vparms_cr) {} + +// TODO +// void ParmsFuncPtr(int (*)(V...)) {} }; %} %template(VariadicParms1) VariadicParms; %template(VariadicParms2) VariadicParms; %template(VariadicParms3) VariadicParms; + + +// #1863 +%inline %{ +class Container { +public: +template +static void notifyMyTypes(void (fn)(Args...)); +}; +%} +%{ +template + void Container::notifyMyTypes(void (fn)(Args...)) {} + +// Explicit template instantiations +template void Container::notifyMyTypes<>(void (tt)()); +template void Container::notifyMyTypes(void (tt)(int)); +template void Container::notifyMyTypes(void (tt)(int, double)); +%} diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 5204c4437..d5fcd2fda 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -5535,11 +5535,6 @@ declarator : pointer notso_direct_declarator { $$.type = $1; SwigType_add_variadic($$.type); } - | ELLIPSIS direct_declarator { - $$ = $2; - if (!$$.type) $$.type = NewStringEmpty(); - SwigType_add_variadic($$.type); - } | AND ELLIPSIS notso_direct_declarator { $$ = $3; $$.type = NewStringEmpty(); @@ -6170,6 +6165,10 @@ rawtype : type_qualifier type_right { SwigType_push($$,$3); SwigType_push($$,$1); } + | rawtype ELLIPSIS { + $$ = $1; + SwigType_add_variadic($$); + } ; type_right : primitive_type { $$ = $1;