From: Jürg Billeter Date: Tue, 16 Sep 2008 13:48:51 +0000 (+0000) Subject: Fix error handling in constructors, patch by Jared Moore, fixes bug 543156 X-Git-Tag: VALA_0_4_0~89 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=691b97fcc2cc4fe73eead2cbefa6eb5c23c6ca65;p=platform%2Fupstream%2Fvala.git Fix error handling in constructors, patch by Jared Moore, fixes bug 543156 2008-09-16 Jürg Billeter * vala/valasemanticanalyzer.vala: * gobject/valaccodegenerator.vala: Fix error handling in constructors, patch by Jared Moore, fixes bug 543156 svn path=/trunk/; revision=1772 --- diff --git a/ChangeLog b/ChangeLog index 5f20f75..0bf26a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2008-09-16 Jürg Billeter + * vala/valasemanticanalyzer.vala: + * gobject/valaccodegenerator.vala: + + Fix error handling in constructors, patch by Jared Moore, + fixes bug 543156 + +2008-09-16 Jürg Billeter + * gobject/valaccodeinvocationexpressionbinding.vala: Support disabling sentinels, patch by Sam Liddicott, diff --git a/THANKS b/THANKS index 46829e0..f2116b9 100644 --- a/THANKS +++ b/THANKS @@ -51,6 +51,7 @@ Rob Taylor Roberto Majadas Roland Hostettler Ross Burton +Sam Liddicott Samuel Cormier-Iijima Stéphan Kochen Tai Chi Minh Ralph Eastwood diff --git a/gobject/valaccodegenerator.vala b/gobject/valaccodegenerator.vala index ecbaf1e..995cb47 100644 --- a/gobject/valaccodegenerator.vala +++ b/gobject/valaccodegenerator.vala @@ -1066,7 +1066,17 @@ public class Vala.CCodeGenerator : CodeGenerator { source_type_member_declaration.append (base_init.copy ()); - base_init.block = (CCodeBlock) c.body.ccodenode; + var block = (CCodeBlock) c.body.ccodenode; + if (current_method_inner_error) { + /* always separate error parameter and inner_error local variable + * as error may be set to NULL but we're always interested in inner errors + */ + var cdecl = new CCodeDeclaration ("GError *"); + cdecl.add_declarator (new CCodeVariableDeclarator.with_initializer ("inner_error", new CCodeConstant ("NULL"))); + block.prepend_statement (cdecl); + } + + base_init.block = block; source_type_member_definition.append (base_init); } else if (c.binding == MemberBinding.STATIC) { diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala index b6871eb..6ef08fd 100644 --- a/vala/valasemanticanalyzer.vala +++ b/vala/valasemanticanalyzer.vala @@ -729,6 +729,10 @@ public class Vala.SemanticAnalyzer : CodeVisitor { c.accept_children (this); + foreach (DataType body_error_type in c.body.get_error_types ()) { + Report.warning (body_error_type.source_reference, "unhandled error `%s'".printf (body_error_type.to_string())); + } + current_symbol = current_symbol.parent_symbol; } @@ -1222,6 +1226,11 @@ public class Vala.SemanticAnalyzer : CodeVisitor { stmt.error_expression.target_type.value_owned = true; stmt.accept_children (this); + + var error_type = stmt.error_expression.value_type.copy (); + error_type.source_reference = stmt.source_reference; + + stmt.add_error_type (error_type); } public override void visit_try_statement (TryStatement stmt) {