From: Jürg Billeter Date: Sat, 23 Jun 2012 14:23:23 +0000 (+0200) Subject: codegen: Fix line directives for ref_sink X-Git-Tag: 0.17.2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9dcec6bca12eb2bd76ce6cb1bab61d0903553506;p=thirdparty%2Fvala.git codegen: Fix line directives for ref_sink Fixes bug 678237. --- diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index 769722a40..fd7fe1782 100644 --- a/codegen/valaccodebasemodule.vala +++ b/codegen/valaccodebasemodule.vala @@ -5291,14 +5291,17 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator { var sink_func = (cl != null) ? get_ccode_ref_sink_function (cl) : ""; if (sink_func != "") { + if (type.nullable) { + var is_not_null = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, result.cvalue, new CCodeIdentifier ("NULL")); + ccode.open_if (is_not_null); + } + var csink = new CCodeFunctionCall (new CCodeIdentifier (sink_func)); csink.add_argument (result.cvalue); + ccode.add_expression (csink); + if (type.nullable) { - var is_not_null = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, result.cvalue, new CCodeIdentifier ("NULL")); - var csink_stat = new CCodeIfStatement (is_not_null, new CCodeExpressionStatement (csink)); - ccode.add_statement (csink_stat); - } else { - ccode.add_expression (csink); + ccode.close (); } } else { Report.error (null, "type `%s' does not support floating references".printf (type.data_type.name));