]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Add G_GNUC_FORMAT attribute for FormatArg function-pointers
authorRico Tzschichholz <ricotz@ubuntu.com>
Mon, 7 Nov 2016 20:03:56 +0000 (21:03 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 7 Nov 2016 20:27:36 +0000 (21:27 +0100)
ccode/valaccodefunctiondeclarator.vala

index fc59aa830bec8e9740cd94b2a8cc61cb99628ccd..08aea1dbcc73e5ea303583f5108710a03b13bc99 100644 (file)
@@ -55,16 +55,23 @@ public class Vala.CCodeFunctionDeclarator : CCodeDeclarator {
                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++;
                }
                
                writer.write_string (")");
+
+               if (format_arg_index >= 0) {
+                       writer.write_string (" G_GNUC_FORMAT(%d)".printf (format_arg_index + 1));
+               }
        }
 }