Bugzilla 88860 - Clarify gcc online manual attribute format printf example

Message ID 750917f3-555a-a5b8-9d55-261b0883153f@jguk.org
State Accepted
Headers
Series Bugzilla 88860 - Clarify gcc online manual attribute format printf example |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Jonny Grant Dec. 26, 2022, 9:04 p.m. UTC
  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(+)
  

Patch

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 88fc625050b..9b200c6f3a0 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -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