Bugzilla 88860 - Clarify gcc online manual attribute format printf example
Checks
Commit Message
2022-12-26 Jonathan Grant <jg@jguk.org>
* gcc/doc/extend.texi: Bugzilla 88860 - Add attribute format printf example
From 1668dc58206428ee92ff142bafb5f545dba029ae Mon Sep 17 00:00:00 2001
From: Jonathan Grant <jg@jguk.org>
Date: Mon, 26 Dec 2022 21:02:35 +0000
Subject: [PATCH] Bugzilla 88860 - Clarify gcc online manual attribute format
printf example
Signed-off-by: Jonathan Grant <jg@jguk.org>
---
gcc/doc/extend.texi | 7 +++++++
1 file changed, 7 insertions(+)
@@ -9353,6 +9353,13 @@ __attribute__((noreturn)) void d0 (void),
the @code{noreturn} attribute applies to all the functions
declared; the @code{format} attribute only applies to @code{d1}.
+@noindent
+The following __attribute__ causes gcc to check run printf argument checks on argument '3' which is 'const char * string format' (when visible at compile time), against argument '4' the '...' variadic ellipsis. In the example below, arguments '1' and '2' are not checked.
+
+@smallexample
+void string_format(const char * prefix, size_t line, const char * const format, ...) __attribute__ ((format (printf,3,4)));
+@end smallexample
+
An attribute specifier list may appear immediately before the comma,
@code{=} or semicolon terminating the declaration of an identifier other
than a function definition. Such attribute specifiers apply