From 6d30c0aa37ffabf26b3c172158a45df514d7670e Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrg=20Billeter?= Date: Sun, 21 Mar 2010 09:51:24 +0100 Subject: [PATCH] Avoic C warnings for some possibly unused functions --- ccode/valaccodefunction.vala | 11 ++++++++++- codegen/valaccodebasemodule.vala | 2 ++ codegen/valagtypemodule.vala | 6 ++++++ codegen/valatyperegisterfunction.vala | 6 +++++- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ccode/valaccodefunction.vala b/ccode/valaccodefunction.vala index 1dfef1b29..2b3775ddf 100644 --- a/ccode/valaccodefunction.vala +++ b/ccode/valaccodefunction.vala @@ -1,6 +1,6 @@ /* valaccodefunction.vala * - * Copyright (C) 2006-2009 Jürg Billeter + * Copyright (C) 2006-2010 Jürg Billeter * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -41,6 +41,8 @@ public class Vala.CCodeFunction : CCodeNode { */ public string return_type { get; set; } + public string attributes { get; set; } + /** * The function body. */ @@ -70,6 +72,7 @@ public class Vala.CCodeFunction : CCodeNode { public CCodeFunction copy () { var func = new CCodeFunction (name, return_type); func.modifiers = modifiers; + func.attributes = attributes; /* no deep copy for lists available yet * func.parameters = parameters.copy (); @@ -109,7 +112,13 @@ public class Vala.CCodeFunction : CCodeNode { } writer.write_string (")"); + if (block == null) { + if (attributes != null) { + writer.write_string (" "); + writer.write_string (attributes); + } + writer.write_string (";"); } else { block.write (writer); diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index dd2a158be..edb496bc6 100644 --- a/codegen/valaccodebasemodule.vala +++ b/codegen/valaccodebasemodule.vala @@ -772,6 +772,8 @@ internal class Vala.CCodeBaseModule : CCodeModule { if (en.access == SymbolAccessibility.PRIVATE) { regfun.modifiers = CCodeModifiers.STATIC; + // avoid C warning as this function is not always used + regfun.attributes = "G_GNUC_UNUSED"; } decl_space.add_type_member_declaration (regfun); diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala index c99a38199..62c1b1d29 100644 --- a/codegen/valagtypemodule.vala +++ b/codegen/valagtypemodule.vala @@ -118,6 +118,8 @@ internal class Vala.GTypeModule : GErrorModule { if (cl.access == SymbolAccessibility.PRIVATE) { function.modifiers = CCodeModifiers.STATIC; + // avoid C warning as this function is not always used + function.attributes = "G_GNUC_UNUSED"; } decl_space.add_type_member_declaration (function); @@ -128,6 +130,8 @@ internal class Vala.GTypeModule : GErrorModule { if (cl.access == SymbolAccessibility.PRIVATE) { function.modifiers = CCodeModifiers.STATIC; + // avoid C warning as this function is not always used + function.attributes = "G_GNUC_UNUSED"; } decl_space.add_type_member_declaration (function); @@ -137,6 +141,8 @@ internal class Vala.GTypeModule : GErrorModule { if (cl.access == SymbolAccessibility.PRIVATE) { function.modifiers = CCodeModifiers.STATIC; + // avoid C warning as this function is not always used + function.attributes = "G_GNUC_UNUSED"; } decl_space.add_type_member_declaration (function); diff --git a/codegen/valatyperegisterfunction.vala b/codegen/valatyperegisterfunction.vala index 4b4ffcb1d..571bca64a 100644 --- a/codegen/valatyperegisterfunction.vala +++ b/codegen/valatyperegisterfunction.vala @@ -1,6 +1,6 @@ /* valatyperegisterfunction.vala * - * Copyright (C) 2006-2009 Jürg Billeter + * Copyright (C) 2006-2010 Jürg Billeter * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -71,6 +71,8 @@ public abstract class Vala.TypeRegisterFunction { /* Function will not be prototyped anyway */ if (get_accessibility () == SymbolAccessibility.PRIVATE) { fun.modifiers = CCodeModifiers.STATIC; + // avoid C warning as this function is not always used + fun.attributes = "G_GNUC_UNUSED"; } } else { fun = new CCodeFunction ("%s_register_type".printf (get_type_declaration ().get_lower_case_cname (null)), "GType"); @@ -79,6 +81,8 @@ public abstract class Vala.TypeRegisterFunction { var get_fun = new CCodeFunction ("%s_get_type".printf (get_type_declaration ().get_lower_case_cname (null)), "GType"); if (get_accessibility () == SymbolAccessibility.PRIVATE) { fun.modifiers = CCodeModifiers.STATIC; + // avoid C warning as this function is not always used + fun.attributes = "G_GNUC_UNUSED"; } declaration_fragment.append (get_fun.copy ()); -- 2.47.3