From 18aa801bd0bf59a7296dd0e045d70bb9c6bbbb6b Mon Sep 17 00:00:00 2001 From: Oliver Buchtala Date: Sun, 5 Aug 2012 08:37:59 +0000 Subject: [PATCH] Fix bug in emit_action. Before, it was possible that two catch(...) blocks were generated (for varargs and undefined typemap). From: Oliver Buchtala git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13511 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/emit.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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"); } }