Fix bug in emit_action.

Before, it was possible that two catch(...) blocks
were generated (for varargs and undefined typemap).

From: Oliver Buchtala <oliver.buchtala@googlemail.com>

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13511 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Oliver Buchtala 2012-08-05 08:37:59 +00:00
commit 18aa801bd0

View file

@ -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");
}
}