Fix error reporting when duplicating non-reference counted objects, fixes
authorJürg Billeter <j@bitron.ch>
Wed, 4 Jun 2008 14:59:08 +0000 (14:59 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Wed, 4 Jun 2008 14:59:08 +0000 (14:59 +0000)
2008-06-04  Jürg Billeter  <j@bitron.ch>

* gobject/valaccodeassignmentbinding.vala:
* gobject/valaccodegenerator.vala:

Fix error reporting when duplicating non-reference counted objects,
fixes bug 535849

svn path=/trunk/; revision=1563

ChangeLog
gobject/valaccodeassignmentbinding.vala
gobject/valaccodegenerator.vala

index 6531820..244d734 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2008-06-04  Jürg Billeter  <j@bitron.ch>
 
+       * gobject/valaccodeassignmentbinding.vala:
+       * gobject/valaccodegenerator.vala:
+
+       Fix error reporting when duplicating non-reference counted objects,
+       fixes bug 535849
+
+2008-06-04  Jürg Billeter  <j@bitron.ch>
+
        * vapigen/valagidlparser.vala:
 
        Support 'cheader_filename' attribute for fields and methods,
index ee75eb4..2506465 100644 (file)
@@ -342,6 +342,11 @@ public class Vala.CCodeAssignmentBinding : CCodeExpressionBinding {
        public override void emit () {
                assignment.accept_children (codegen);
 
+               if (assignment.left.error || assignment.right.error) {
+                       assignment.error = true;
+                       return;
+               }
+
                if (assignment.left.symbol_reference is Property) {
                        emit_property_assignment ();
                } else if (assignment.left.symbol_reference is Signal) {
index ba04fa6..d089b10 100644 (file)
@@ -1075,6 +1075,10 @@ public class Vala.CCodeGenerator : CodeGenerator {
                var cblock = new CCodeBlock ();
                
                foreach (CodeNode stmt in b.get_statements ()) {
+                       if (stmt.error) {
+                               continue;
+                       }
+
                        var src = stmt.source_reference;
                        if (src != null && src.comment != null) {
                                cblock.add_statement (new CCodeComment (src.comment));
@@ -1663,6 +1667,11 @@ public class Vala.CCodeGenerator : CodeGenerator {
        }
 
        public override void visit_expression_statement (ExpressionStatement stmt) {
+               if (stmt.expression.error) {
+                       stmt.error = true;
+                       return;
+               }
+
                stmt.ccodenode = new CCodeExpressionStatement ((CCodeExpression) stmt.expression.ccodenode);
 
                if (stmt.tree_can_fail && stmt.expression.tree_can_fail) {
@@ -3521,7 +3530,11 @@ public class Vala.CCodeGenerator : CodeGenerator {
                if (target_type.value_owned && (!expression_type.value_owned || boxing || unboxing)) {
                        // need to copy value
                        if (requires_copy (target_type) && !(expression_type is NullType)) {
-                               cexpr = get_ref_cexpression (target_type, cexpr, expr, expression_type);
+                               CodeNode node = expr;
+                               if (node == null) {
+                                       node = expression_type;
+                               }
+                               cexpr = get_ref_cexpression (target_type, cexpr, expr, node);
                        }
                }