From e6e931b7c534a23faeb47e8ce039de500cb6ccd3 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Thu, 23 Sep 2004 17:11:24 +0100 Subject: [PATCH] re PR c/16833 (-fno-builtin prevents automatic format checks for standard functions) 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. From-SVN: r87957 --- gcc/ChangeLog | 8 ++++++++ gcc/doc/extend.texi | 6 ++++-- gcc/doc/invoke.texi | 15 ++++++++++++++- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 93ad667c95e..3c44c68c815 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2004-09-23 Joseph S. Myers + + 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. + 2004-09-23 Frank Ch. Eigler PR tree-optimization/17533 diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index af5b9d17755..a407663ae10 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -1764,10 +1764,11 @@ start with the third argument, so the correct parameters for the format 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 @@ type function whose operands are a call to one of your own function. 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 --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index fae30188b20..e86677d3ecc 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -1173,7 +1173,14 @@ instructions that adjust the stack directly, and calls to @code{memcpy} 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 @@ messages. @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 @@ sense. This includes standard functions, and others specified by format 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 -- 2.30.2