Commit bb72a084 by Paul Eggert Committed by Jeff Law

This change is from an idea suggested by Arthur David Olson.

	* c-common.c (decl_attributes, record_function_format,
	check_format_info, init_function_format_info):
	Add support for strftime format checking.
	(enum format_type): New type.
	(record_function_format): Now static, and takes value of type
	enum format_type instead of int.
	(time_char_table): New constant.
	(struct function_format_info): format_type member renamed from is_scan.
	(check_format_info): Use `warning' rather than sprintf followed by
	`warning', to avoid mishandling `%' in warnings.
	Change `pedwarn' to `warning', since these warnings do not necessarily
	mean the program does not conform to the C Standard, as the code
	need not be executed.
	* c-tree.h (record_function_format): Remove decl; no longer extern.
	* extend.texi: Add documentation for strftime format checking.

From-SVN: r19151
parent 71922625
1998-04-12 Paul Eggert <eggert@twinsun.com>
This change is from an idea suggested by Arthur David Olson.
* c-common.c (decl_attributes, record_function_format,
check_format_info, init_function_format_info):
Add support for strftime format checking.
(enum format_type): New type.
(record_function_format): Now static, and takes value of type
enum format_type instead of int.
(time_char_table): New constant.
(struct function_format_info): format_type member renamed from is_scan.
(check_format_info): Use `warning' rather than sprintf followed by
`warning', to avoid mishandling `%' in warnings.
Change `pedwarn' to `warning', since these warnings do not necessarily
mean the program does not conform to the C Standard, as the code
need not be executed.
* c-tree.h (record_function_format): Remove decl; no longer extern.
* extend.texi: Add documentation for strftime format checking.
Sun Apr 12 20:23:03 1998 Jeffrey A Law (law@cygnus.com)
* mips/ecoffl.h: Do not include mips.h.
......
......@@ -162,7 +162,6 @@ extern void gen_aux_info_record PROTO((tree, int, int, int));
extern void declare_function_name PROTO((void));
extern void decl_attributes PROTO((tree, tree, tree));
extern void init_function_format_info PROTO((void));
extern void record_function_format PROTO((tree, tree, int, int, int));
extern void check_function_format PROTO((tree, tree, tree));
/* Print an error message for invalid operands to arith operation CODE.
NOP_EXPR is used as a special case (see truthvalue_conversion). */
......
......@@ -1274,7 +1274,7 @@ hack ((union foo) x);
@cindex functions in arbitrary sections
@cindex @code{volatile} applied to function
@cindex @code{const} applied to function
@cindex functions with @code{printf} or @code{scanf} style arguments
@cindex functions with @code{printf}, @code{scanf} or @code{strftime} style arguments
@cindex functions that are passed arguments in registers on the 386
@cindex functions that pop the argument stack on the 386
@cindex functions that do not pop the argument stack on the 386
......@@ -1378,9 +1378,9 @@ return @code{void}.
@item format (@var{archetype}, @var{string-index}, @var{first-to-check})
@cindex @code{format} function attribute
The @code{format} attribute specifies that a function takes @code{printf}
or @code{scanf} style arguments which should be type-checked against a
format string. For example, the declaration:
The @code{format} attribute specifies that a function takes @code{printf},
@code{scanf}, or @code{strftime} style arguments which should be type-checked
against a format string. For example, the declaration:
@smallexample
extern int
......@@ -1394,7 +1394,8 @@ for consistency with the @code{printf} style format string argument
@code{my_format}.
The parameter @var{archetype} determines how the format string is
interpreted, and should be either @code{printf} or @code{scanf}. The
interpreted, and should be either @code{printf}, @code{scanf}, or
@code{strftime}. The
parameter @var{string-index} specifies which argument is the format
string argument (starting from 1), while @var{first-to-check} is the
number of the first argument to check against the format string. For
......@@ -1411,7 +1412,7 @@ The @code{format} attribute allows you to identify your own functions
which take format strings as arguments, so that GNU CC can check the
calls to these functions for errors. The compiler always checks formats
for the ANSI library functions @code{printf}, @code{fprintf},
@code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf},
@code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
@code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
warnings are requested (using @samp{-Wformat}), so there is no need to
modify the header file @file{stdio.h}.
......@@ -1431,18 +1432,19 @@ my_dgettext (char *my_domain, const char *my_format)
@noindent
causes the compiler to check the arguments in calls to
@code{my_dgettext} whose result is passed to a @code{printf} or
@code{scanf} type function for consistency with the @code{printf} style
format string argument @code{my_format}.
@code{my_dgettext} whose result is passed to a @code{printf},
@code{scanf}, or @code{strftime} type function for consistency with the
@code{printf} style format string argument @code{my_format}.
The parameter @var{string-index} specifies which argument is the format
string argument (starting from 1).
The @code{format-arg} attribute allows you to identify your own
functions which modify format strings, so that GNU CC can check the
calls to @code{printf} and @code{scanf} 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.
calls to @code{printf}, @code{scanf}, or @code{strftime} 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.
@item section ("section-name")
@cindex @code{section} function attribute
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment