diff --git a/Source/Modules/emit.cxx b/Source/Modules/emit.cxx index efcf9a352..7d7f66eaf 100644 --- a/Source/Modules/emit.cxx +++ b/Source/Modules/emit.cxx @@ -470,6 +470,7 @@ String *emit_action(Node *n) { if (catchlist) { int unknown_catch = 0; + int has_varargs = 0; Printf(eaction, "}\n"); for (Parm *ep = catchlist; ep; ep = nextSibling(ep)) { String *em = Swig_typemap_lookup("throws", ep, "_e", 0); @@ -480,6 +481,7 @@ String *emit_action(Node *n) { Printf(eaction, "catch(%s) {", SwigType_str(et, "_e")); } else if (SwigType_isvarargs(etr)) { Printf(eaction, "catch(...) {"); + has_varargs = 1; } else { Printf(eaction, "catch(%s) {", SwigType_str(et, "&_e")); } @@ -490,8 +492,8 @@ String *emit_action(Node *n) { unknown_catch = 1; } } - if (unknown_catch) { - Printf(eaction, "catch(...) { throw; }\n"); + if (unknown_catch && !has_varargs) { + Printf(eaction, "catch(...) { throw; }\n"); } }