Patch for bug 16833

Joseph S. Myers jsm@polyomino.org.uk
Thu Sep 23 17:50:00 GMT 2004


This patch fixes bug 16833 by documenting the interaction between
-fno-builtin and format checks.

It passes "make info" and "make dvi".  Applied to mainline.

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
  http://www.srcf.ucam.org/~jsm28/gcc/#c90status - status of C90 for GCC 4.0
    jsm@polyomino.org.uk (personal mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)

2004-09-23  Joseph S. Myers  <jsm@polyomino.org.uk>

	PR c/16833
	* doc/extend.texi, doc/invoke.texi: Document interaction of
	-fno-builtin with format checks.  Note that built-in functions
	have effects beyond generating code that avoids calls to those
	functions.

diff -ruN doc.orig/extend.texi doc/extend.texi
--- doc.orig/extend.texi	2004-09-17 18:14:27.000000000 +0000
+++ doc/extend.texi	2004-09-23 14:40:26.000000000 +0000
@@ -1764,10 +1764,11 @@
 attribute are 2 and 3.
 
 @opindex ffreestanding
+@opindex fno-builtin
 The @code{format} attribute allows you to identify your own functions
 which take format strings as arguments, so that GCC can check the
 calls to these functions for errors.  The compiler always (unless
-@option{-ffreestanding} is used) checks formats
+@option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
 for the standard library functions @code{printf}, @code{fprintf},
 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
@@ -1824,7 +1825,8 @@
 The compiler always treats @code{gettext}, @code{dgettext}, and
 @code{dcgettext} in this manner except when strict ISO C support is
 requested by @option{-ansi} or an appropriate @option{-std} option, or
-@option{-ffreestanding} is used.  @xref{C Dialect Options,,Options
+@option{-ffreestanding} or @option{-fno-builtin}
+is used.  @xref{C Dialect Options,,Options
 Controlling C Dialect}.
 
 @item function_vector
diff -ruN doc.orig/invoke.texi doc/invoke.texi
--- doc.orig/invoke.texi	2004-09-17 18:14:27.000000000 +0000
+++ doc/invoke.texi	2004-09-23 14:48:08.000000000 +0000
@@ -1173,7 +1173,14 @@
 may become inline copy loops.  The resulting code is often both smaller
 and faster, but since the function calls no longer appear as such, you
 cannot set a breakpoint on those calls, nor can you change the behavior
-of the functions by linking with a different library.
+of the functions by linking with a different library.  In addition,
+when a function is recognized as a built-in function, GCC may use
+information about that function to warn about problems with calls to
+that function, or to generate more efficient code, even if the
+resulting code still contains calls to that function.  For example,
+warnings are given with @option{-Wformat} for bad calls to
+@code{printf}, when @code{printf} is built in, and @code{strlen} is
+known not to modify global memory.
 
 With the @option{-fno-builtin-@var{function}} option
 only the built-in function @var{function} is
@@ -2161,6 +2168,8 @@
 
 @item -Wformat
 @opindex Wformat
+@opindex ffreestanding
+@opindex fno-builtin
 Check calls to @code{printf} and @code{scanf}, etc., to make sure that
 the arguments supplied have types appropriate to the format string
 specified, and that the conversions specified in the format string make
@@ -2168,6 +2177,10 @@
 attributes (@pxref{Function Attributes}), in the @code{printf},
 @code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension,
 not in the C standard) families (or other target-specific families).
+Which functions are checked without format attributes having been
+specified depends on the standard version selected, and such checks of
+functions without the attribute specified are disabled by
+@option{-ffreestanding} or @option{-fno-builtin}.
 
 The formats are checked against the format features supported by GNU
 libc version 2.2.  These include all ISO C90 and C99 features, as well



More information about the Gcc-patches mailing list