[vala/temp] codegen: Open block for try statements



commit 5de8a9571708165d9d018aca03770adf3d35b015
Author: Luca Bruno <lucabru src gnome org>
Date:   Thu May 26 16:53:50 2011 +0200

    codegen: Open block for try statements
    
    Fixes bug 651145.

 codegen/valaccodebasemodule.vala |    4 ++--
 tests/Makefile.am                |    1 +
 tests/errors/bug651145.vala      |    8 ++++++++
 3 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index b4efc50..2445bc7 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -1669,7 +1669,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
 		var local_vars = b.get_local_variables ();
 
-		if (b.parent_node is Block || b.parent_node is SwitchStatement) {
+		if (b.parent_node is Block || b.parent_node is SwitchStatement || b.parent_node is TryStatement) {
 			ccode.open_block ();
 		}
 
@@ -1954,7 +1954,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 			ccode.add_assignment (get_variable_cexpression ("_data%d_".printf (block_id)), new CCodeConstant ("NULL"));
 		}
 
-		if (b.parent_node is Block || b.parent_node is SwitchStatement) {
+		if (b.parent_node is Block || b.parent_node is SwitchStatement || b.parent_node is TryStatement) {
 			ccode.close ();
 		}
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 422571e..a990d9c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -88,6 +88,7 @@ TESTS = \
 	errors/bug596228.vala \
 	errors/bug623049.vala \
 	errors/bug639589.vala \
+	errors/bug651145.vala \
 	asynchronous/bug595735.vala \
 	asynchronous/bug595755.vala \
 	asynchronous/bug596177.vala \
diff --git a/tests/errors/bug651145.vala b/tests/errors/bug651145.vala
new file mode 100644
index 0000000..06fa14a
--- /dev/null
+++ b/tests/errors/bug651145.vala
@@ -0,0 +1,8 @@
+void main () {
+	try {
+		string foo;
+	} finally {}
+	try {
+		string foo;
+	} finally {}
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]