From: Jürg Billeter Date: Thu, 21 Oct 2010 08:18:40 +0000 (+0200) Subject: codegen: Fix C warning in destructors X-Git-Tag: 0.11.1~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cfc03c4907a20da8c97bdbee9f52881b813f885d;p=thirdparty%2Fvala.git codegen: Fix C warning in destructors --- diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index 561f535dc..678d139b5 100644 --- a/codegen/valaccodebasemodule.vala +++ b/codegen/valaccodebasemodule.vala @@ -36,6 +36,7 @@ public class Vala.CCodeBaseModule : CodeGenerator { public ArrayList temp_ref_vars = new ArrayList (); public int next_temp_var_id; public bool current_method_inner_error; + public bool current_method_return; public Map variable_name_map = new HashMap (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_map = new HashMap (); @@ -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) { diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala index 61c61f117..9ad6b0848 100644 --- a/codegen/valagtypemodule.vala +++ b/codegen/valagtypemodule.vala @@ -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 ();