]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Fix C warning in destructors
authorJürg Billeter <j@bitron.ch>
Thu, 21 Oct 2010 08:18:40 +0000 (10:18 +0200)
committerJürg Billeter <j@bitron.ch>
Thu, 21 Oct 2010 08:18:40 +0000 (10:18 +0200)
codegen/valaccodebasemodule.vala
codegen/valagtypemodule.vala

index 561f535dc72174d91095432e92c81b356bf33fc2..678d139b558569fe7b9bcf3aafaf73ecc28a25d8 100644 (file)
@@ -36,6 +36,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
                public ArrayList<LocalVariable> temp_ref_vars = new ArrayList<LocalVariable> ();
                public int next_temp_var_id;
                public bool current_method_inner_error;
+               public bool current_method_return;
                public Map<string,string> variable_name_map = new HashMap<string,string> (str_hash, str_equal);
 
                public EmitContext (Symbol? symbol = null) {
@@ -215,6 +216,11 @@ public class Vala.CCodeBaseModule : CodeGenerator {
                set { emit_context.current_method_inner_error = value; }
        }
 
+       public bool current_method_return {
+               get { return emit_context.current_method_return; }
+               set { emit_context.current_method_return = value; }
+       }
+
        public int next_coroutine_state = 1;
        int next_block_id = 0;
        Map<Block,int> block_map = new HashMap<Block,int> ();
@@ -3371,6 +3377,9 @@ public class Vala.CCodeBaseModule : CodeGenerator {
                if (return_expression_symbol != null) {
                        return_expression_symbol.active = true;
                }
+
+               // required for destructors
+               current_method_return = true;
        }
 
        public string get_symbol_lock_name (string symname) {
index 61c61f11750c18dd7c47ab93e1782413db1eb207..9ad6b084896f3b8febffd702b2371478141cdf6d 100644 (file)
@@ -1654,8 +1654,10 @@ public class Vala.GTypeModule : GErrorModule {
                                ccode.add_declaration ("GError *", new CCodeVariableDeclarator.zero ("_inner_error_", new CCodeConstant ("NULL")));
                        }
 
-                       // support return statements in destructors
-                       ccode.add_label ("_return");
+                       if (current_method_return) {
+                               // support return statements in destructors
+                               ccode.add_label ("_return");
+                       }
                }
 
                pop_context ();