diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2017-08-27 09:11:48 +0200 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2017-08-27 09:11:48 +0200 |
commit | 5c12ee63704bbb3a897df157f9413005e7dadb0e (patch) | |
tree | 1204c32f705159ee68b9401e5e76ba574102efc3 /codegen | |
parent | 4056b1c18cd93cac40f1a442fd0238d48cf11cff (diff) | |
download | vala-5c12ee63704bbb3a897df157f9413005e7dadb0e.tar.gz |
codegen: Adjust format-index for printf/scanf-methods which throw errors
If there is no explicit FormatArg annotation while this method throws an
error, it is required to mark the parameter located right before ellipsis
as format-arg to account for the parameter shifting caused by the inserted
GError parameter.
https://bugzilla.gnome.org/show_bug.cgi?id=781061
Diffstat (limited to 'codegen')
-rw-r--r-- | codegen/valaccodemethodmodule.vala | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala index 744bf7d6e..4efd04b72 100644 --- a/codegen/valaccodemethodmodule.vala +++ b/codegen/valaccodemethodmodule.vala @@ -1008,6 +1008,9 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule { } } + var needs_format_arg = m.get_format_arg_index () < 0 && (m.printf_format || m.scanf_format); + + CCodeParameter? prev_cparam = null; foreach (Parameter param in m.get_parameters ()) { if (param.direction != ParameterDirection.OUT) { if ((direction & 1) == 0) { @@ -1021,7 +1024,17 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule { } } - generate_parameter (param, decl_space, cparam_map, carg_map); + var cparam = generate_parameter (param, decl_space, cparam_map, carg_map); + + // if there is no explicit FormatArg annotation while this method throws an error + // it is required to mark the parameter located right before ellipsis as format-arg + // to account for the parameter shifting caused by the inserted GError parameter + if (needs_format_arg) { + if (prev_cparam != null && cparam.ellipsis) { + prev_cparam.modifiers |= CCodeModifiers.FORMAT_ARG; + } + prev_cparam = cparam; + } } if ((direction & 2) != 0) { |