The initial implementation of __attribute__((format)) on non-variadic functions accidentally only accepted one data argument. This worked:
__attribute__((format(printf, 1, 2))) void f(const char *, int);
but this didn't:
__attribute__((format(printf, 1, 2))) void f(const char *, int, int);
This is due to an oversight in changing the way diagnostics are emitted for attribute((format)), and to a coincidence in the handling of the variadic case. Test cases only covered the case that worked by coincidence.
Before the previous change, using __attribute__((format)) on a non-variadic function at all was an error and clang bailed out. After that change, it only generates a GCC compatibility warning. However, as execution falls through, it hits a second diagnostic when the first data argument is neither 0 nor the last parameter of the function.
This change updates that check to allow any parameter after the format string to be the first data argument when the function is non-variadic. When the function is variadic, it still needs to be the index of the ... "parameter". Attribute documentation is updated to reflect the change and new tests are added to verify that it works with two data parameters.