]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Do not check unexpected errors within finally blocks
authorJürg Billeter <j@bitron.ch>
Thu, 4 Feb 2010 19:46:02 +0000 (20:46 +0100)
committerJürg Billeter <j@bitron.ch>
Thu, 4 Feb 2010 19:46:30 +0000 (20:46 +0100)
Jump out of finally block is not supported.

codegen/valagerrormodule.vala

index b00438f12cccfde7f70d83a568942b79dd4eb3fd..28d23e9a6a7e58b889871aa07c8e539838237e80 100644 (file)
@@ -176,6 +176,18 @@ internal class Vala.GErrorModule : CCodeDelegateModule {
                return cerror_block;
        }
 
+       bool in_finally_block (CodeNode node) {
+               var current_node = node;
+               while (current_node != null) {
+                       var try_stmt = current_node.parent_node as TryStatement;
+                       if (try_stmt != null && try_stmt.finally_body == current_node) {
+                               return true;
+                       }
+                       current_node = current_node.parent_node;
+               }
+               return false;
+       }
+
        public override void add_simple_check (CodeNode node, CCodeFragment cfrag) {
                current_method_inner_error = true;
 
@@ -247,6 +259,9 @@ internal class Vala.GErrorModule : CCodeDelegateModule {
                                // go to finally clause if no catch clause matches
                                // and there are still unhandled error types
                                cerror_block.add_statement (new CCodeGotoStatement ("__finally%d".printf (current_try_id)));
+                       } else if (in_finally_block (node)) {
+                               // do not check unexpected errors happening within finally blocks
+                               // as jump out of finally block is not supported
                        } else {
                                // should never happen with correct bindings
                                uncaught_error_statement (inner_error, cerror_block, true);