diff options
author | Jürg Billeter <j@bitron.ch> | 2016-11-07 20:23:38 +0100 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2016-11-07 21:27:36 +0100 |
commit | ab96b471875951fb0c85188b220d275c4496b955 (patch) | |
tree | 007256b92f03bae535c6d8c583b63b849672bcea /ccode | |
parent | 08880b13303d365d03667d8bb8254711595c88af (diff) | |
download | vala-ab96b471875951fb0c85188b220d275c4496b955.tar.gz |
codegen: Add G_GNUC_FORMAT attribute for FormatArg functions
https://bugzilla.gnome.org/show_bug.cgi?id=774060
Diffstat (limited to 'ccode')
-rw-r--r-- | ccode/valaccodefunction.vala | 17 | ||||
-rw-r--r-- | ccode/valaccodeparameter.vala | 2 |
2 files changed, 14 insertions, 5 deletions
diff --git a/ccode/valaccodefunction.vala b/ccode/valaccodefunction.vala index 7f3b3bb12..44dd5b956 100644 --- a/ccode/valaccodefunction.vala +++ b/ccode/valaccodefunction.vala @@ -126,16 +126,19 @@ public class Vala.CCodeFunction : CCodeNode { writer.write_string (name); writer.write_string (" ("); - bool first = true; + int i = 0; + int format_arg_index = -1; foreach (CCodeParameter param in parameters) { - if (!first) { + if (i > 0) { writer.write_string (", "); - } else { - first = false; } param.write (writer); + if (param.format_arg) { + format_arg_index = i; + } + i++; } - if (first) { + if (i == 0) { writer.write_string ("void"); } @@ -146,6 +149,10 @@ public class Vala.CCodeFunction : CCodeNode { } if (is_declaration) { + if (format_arg_index >= 0) { + writer.write_string (" G_GNUC_FORMAT(%d)".printf (format_arg_index + 1)); + } + if (attributes != null) { writer.write_string (" "); writer.write_string (attributes); diff --git a/ccode/valaccodeparameter.vala b/ccode/valaccodeparameter.vala index 9f1c2e186..9404f470c 100644 --- a/ccode/valaccodeparameter.vala +++ b/ccode/valaccodeparameter.vala @@ -42,6 +42,8 @@ public class Vala.CCodeParameter : CCodeNode { */ public bool ellipsis { get; set; } + public bool format_arg { get; set; } + public CCodeParameter (string n, string type) { name = n; type_name = type; |