vala r2288 - in trunk: . gobject
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r2288 - in trunk: . gobject
- Date: Wed, 7 Jan 2009 22:20:55 +0000 (UTC)
Author: juergbi
Date: Wed Jan 7 22:20:54 2009
New Revision: 2288
URL: http://svn.gnome.org/viewvc/vala?rev=2288&view=rev
Log:
2009-01-07 JÃrg Billeter <j bitron ch>
* gobject/valagerrormodule.vala:
Handle errors that occur within a try block but are not handled
by a catch clause, fixes bug 533929
Modified:
trunk/ChangeLog
trunk/gobject/valagerrormodule.vala
Modified: trunk/gobject/valagerrormodule.vala
==============================================================================
--- trunk/gobject/valagerrormodule.vala (original)
+++ trunk/gobject/valagerrormodule.vala Wed Jan 7 22:20:54 2009
@@ -102,7 +102,6 @@
if (current_try != null) {
// surrounding try found
- // TODO might be the wrong one when using nested try statements
var cerror_block = new CCodeBlock ();
@@ -127,8 +126,9 @@
cerror_block.add_statement (new CCodeIfStatement (ccond, cgoto_block));
}
}
- // print critical message if no catch clause matches
- cerror_block.add_statement (cprint_frag);
+
+ // go to finally clause if no catch clause matches
+ cerror_block.add_statement (new CCodeGotoStatement ("__finally%d".printf (current_try_id)));
// check error domain if expression failed
var ccond = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, get_variable_cexpression ("inner_error"), new CCodeConstant ("NULL"));
@@ -172,6 +172,12 @@
// print critical message
cerror_block.add_statement (cprint_frag);
+ if (current_return_type is VoidType) {
+ cerror_block.add_statement (new CCodeReturnStatement ());
+ } else if (current_return_type != null) {
+ cerror_block.add_statement (new CCodeReturnStatement (default_value_for_type (current_return_type, false)));
+ }
+
// check error domain if expression failed
var ccond = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, get_variable_cexpression ("inner_error"), new CCodeConstant ("NULL"));
@@ -220,11 +226,12 @@
cfrag.append (new CCodeLabel ("__finally%d".printf (this_try_id)));
if (stmt.finally_body != null) {
cfrag.append (stmt.finally_body.ccodenode);
- } else {
- // avoid gcc error: label at end of compound statement
- cfrag.append (new CCodeEmptyStatement ());
}
+ // check for errors not handled by this try statement
+ // may be handled by outer try statements or propagated
+ add_simple_check (stmt, cfrag);
+
stmt.ccodenode = cfrag;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]