invoke.texi (Wmissing-format-attribute): Document as an alias of Wsuggest-attribute=format.

2012-04-30  Manuel López-Ibáñez  <manu@gcc.gnu.org>

gcc/
	* doc/invoke.texi (Wmissing-format-attribute): Document as an
	alias of Wsuggest-attribute=format.
c-family/
	* c.opt (Wsuggest-attribute=format): New. Alias of
	Wmissing-format-attribute.
	* c-format.c (decode_format_type): Replace
	Wmissing-format-attribute with Wsuggest-attribute=format.
	(check_function_format): Likewise.
cp/
	* typeck.c (convert_for_assignment):  Replace
	Wmissing-format-attribute with Wsuggest-attribute=format.
	* call.c (convert_for_arg_passing): Likewise.
gcc/
	* c-typeck.c (convert_for_assignment): Replace
	Wmissing-format-attribute with Wsuggest-attribute=format.
	(digest_init): Likewise.

From-SVN: r186955
This commit is contained in:
Manuel López-Ibáñez 2012-04-30 07:42:42 +00:00
parent 70c33a85a6
commit 90137d8f2c
9 changed files with 77 additions and 46 deletions

View File

@ -1,3 +1,11 @@
2012-04-30 Manuel López-Ibáñez <manu@gcc.gnu.org>
* doc/invoke.texi (Wmissing-format-attribute): Document as an
alias of Wsuggest-attribute=format.
* c-typeck.c (convert_for_assignment): Replace
Wmissing-format-attribute with Wsuggest-attribute=format.
(digest_init): Likewise.
2012-04-29 Manuel López-Ibáñez <manu@gcc.gnu.org>
* opts.c (finish_options): Do not handle -Wmissing-noreturn here.

View File

@ -1,3 +1,11 @@
2012-04-30 Manuel López-Ibáñez <manu@gcc.gnu.org>
* c.opt (Wsuggest-attribute=format): New. Alias of
Wmissing-format-attribute.
* c-format.c (decode_format_type): Replace
Wmissing-format-attribute with Wsuggest-attribute=format.
(check_function_format): Likewise.
2012-04-27 Ollie Wild <aaw@google.com>
* c-common.c: Add CPP_W_LITERAL_SUFFIX mapping.

View File

@ -1005,7 +1005,7 @@ decode_format_type (const char *s)
/* Check the argument list of a call to printf, scanf, etc.
ATTRS are the attributes on the function type. There are NARGS argument
values in the array ARGARRAY.
Also, if -Wmissing-format-attribute,
Also, if -Wsuggest-attribute=format,
warn for calls to vprintf or vscanf in functions with no such format
attribute themselves. */
@ -1033,7 +1033,7 @@ check_function_format (tree attrs, int nargs, tree *argarray)
params = tree_cons (NULL_TREE, argarray[i], params);
check_format_info (&info, params);
}
if (warn_missing_format_attribute && info.first_arg_num == 0
if (warn_suggest_attribute_format && info.first_arg_num == 0
&& (format_types[info.format_type].flags
& (int) FMT_FLAG_ARG_CONVERT))
{
@ -1063,7 +1063,7 @@ check_function_format (tree attrs, int nargs, tree *argarray)
break;
}
if (args != 0)
warning (OPT_Wmissing_format_attribute, "function might "
warning (OPT_Wsuggest_attribute_format, "function might "
"be possible candidate for %qs format attribute",
format_types[info.format_type].name);
}

View File

@ -477,10 +477,14 @@ Wmissing-field-initializers
C ObjC C++ ObjC++ Var(warn_missing_field_initializers) Init(-1) Warning
Warn about missing fields in struct initializers
Wmissing-format-attribute
C ObjC C++ ObjC++ Var(warn_missing_format_attribute) Warning
Wsuggest-attribute=format
C ObjC C++ ObjC++ Var(warn_suggest_attribute_format) Warning
Warn about functions which might be candidates for format attributes
Wmissing-format-attribute
C ObjC C++ ObjC++ Alias(Wsuggest-attribute=format)
;
Wmissing-include-dirs
C ObjC C++ ObjC++ Warning
Warn about user-specified include directories that do not exist

View File

@ -5594,29 +5594,29 @@ convert_for_assignment (location_t location, tree type, tree rhs,
/* Check if the right-hand side has a format attribute but the
left-hand side doesn't. */
if (warn_missing_format_attribute
if (warn_suggest_attribute_format
&& check_missing_format_attribute (type, rhstype))
{
switch (errtype)
{
case ic_argpass:
warning_at (location, OPT_Wmissing_format_attribute,
warning_at (location, OPT_Wsuggest_attribute_format,
"argument %d of %qE might be "
"a candidate for a format attribute",
parmnum, rname);
break;
case ic_assign:
warning_at (location, OPT_Wmissing_format_attribute,
warning_at (location, OPT_Wsuggest_attribute_format,
"assignment left-hand side might be "
"a candidate for a format attribute");
break;
case ic_init:
warning_at (location, OPT_Wmissing_format_attribute,
warning_at (location, OPT_Wsuggest_attribute_format,
"initialization left-hand side might be "
"a candidate for a format attribute");
break;
case ic_return:
warning_at (location, OPT_Wmissing_format_attribute,
warning_at (location, OPT_Wsuggest_attribute_format,
"return type might be "
"a candidate for a format attribute");
break;
@ -6335,7 +6335,7 @@ digest_init (location_t init_loc, tree type, tree init, tree origtype,
pedwarn_init (init_loc, 0,
"initializer element is not a constant expression");
/* Added to enable additional -Wmissing-format-attribute warnings. */
/* Added to enable additional -Wsuggest-attribute=format warnings. */
if (TREE_CODE (TREE_TYPE (inside_init)) == POINTER_TYPE)
inside_init = convert_for_assignment (init_loc, type, inside_init,
origtype,

View File

@ -1,3 +1,9 @@
2012-04-30 Manuel López-Ibáñez <manu@gcc.gnu.org>
* typeck.c (convert_for_assignment): Replace
Wmissing-format-attribute with Wsuggest-attribute=format.
* call.c (convert_for_arg_passing): Likewise.
2012-04-26 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/53096

View File

@ -6321,7 +6321,7 @@ convert_for_arg_passing (tree type, tree val, tsubst_flags_t complain)
TYPE_SIZE (integer_type_node)))
val = perform_integral_promotions (val);
if ((complain & tf_warning)
&& warn_missing_format_attribute)
&& warn_suggest_attribute_format)
{
tree rhstype = TREE_TYPE (val);
const enum tree_code coder = TREE_CODE (rhstype);
@ -6329,7 +6329,7 @@ convert_for_arg_passing (tree type, tree val, tsubst_flags_t complain)
if ((codel == POINTER_TYPE || codel == REFERENCE_TYPE)
&& coder == codel
&& check_missing_format_attribute (type, rhstype))
warning (OPT_Wmissing_format_attribute,
warning (OPT_Wsuggest_attribute_format,
"argument of function call might be a candidate for a format attribute");
}
return val;

View File

@ -7624,7 +7624,7 @@ convert_for_assignment (tree type, tree rhs,
return error_mark_node;
}
}
if (warn_missing_format_attribute)
if (warn_suggest_attribute_format)
{
const enum tree_code codel = TREE_CODE (type);
if ((codel == POINTER_TYPE || codel == REFERENCE_TYPE)
@ -7636,31 +7636,31 @@ convert_for_assignment (tree type, tree rhs,
case ICR_ARGPASS:
case ICR_DEFAULT_ARGUMENT:
if (fndecl)
warning (OPT_Wmissing_format_attribute,
warning (OPT_Wsuggest_attribute_format,
"parameter %qP of %qD might be a candidate "
"for a format attribute", parmnum, fndecl);
else
warning (OPT_Wmissing_format_attribute,
warning (OPT_Wsuggest_attribute_format,
"parameter might be a candidate "
"for a format attribute");
break;
case ICR_CONVERTING:
warning (OPT_Wmissing_format_attribute,
warning (OPT_Wsuggest_attribute_format,
"target of conversion might be a candidate "
"for a format attribute");
break;
case ICR_INIT:
warning (OPT_Wmissing_format_attribute,
warning (OPT_Wsuggest_attribute_format,
"target of initialization might be a candidate "
"for a format attribute");
break;
case ICR_RETURN:
warning (OPT_Wmissing_format_attribute,
warning (OPT_Wsuggest_attribute_format,
"return type might be a candidate "
"for a format attribute");
break;
case ICR_ASSIGN:
warning (OPT_Wmissing_format_attribute,
warning (OPT_Wsuggest_attribute_format,
"left-hand side of assignment might be a candidate "
"for a format attribute");
break;

View File

@ -255,7 +255,7 @@ Objective-C and Objective-C++ Dialects}.
-Winvalid-pch -Wlarger-than=@var{len} -Wunsafe-loop-optimizations @gol
-Wlogical-op -Wlong-long @gol
-Wmain -Wmaybe-uninitialized -Wmissing-braces -Wmissing-field-initializers @gol
-Wmissing-format-attribute -Wmissing-include-dirs @gol
-Wmissing-include-dirs @gol
-Wno-mudflap @gol
-Wno-multichar -Wnonnull -Wno-overflow @gol
-Woverlength-strings -Wpacked -Wpacked-bitfield-compat -Wpadded @gol
@ -266,7 +266,8 @@ Objective-C and Objective-C++ Dialects}.
-Wsign-compare -Wsign-conversion -Wstack-protector @gol
-Wstack-usage=@var{len} -Wstrict-aliasing -Wstrict-aliasing=n @gol
-Wstrict-overflow -Wstrict-overflow=@var{n} @gol
-Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{]} @gol
-Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{]} @gol
-Wmissing-format-attribute @gol
-Wswitch -Wswitch-default -Wswitch-enum -Wsync-nand @gol
-Wsystem-headers -Wtrampolines -Wtrigraphs -Wtype-limits -Wundef @gol
-Wuninitialized -Wunknown-pragmas -Wno-pragmas @gol
@ -3860,7 +3861,7 @@ comparisons, so this warning level gives a very large number of
false positives.
@end table
@item -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{]}
@item -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{]}
@opindex Wsuggest-attribute=
@opindex Wno-suggest-attribute=
Warn for cases where adding an attribute may be beneficial. The
@ -3885,6 +3886,33 @@ returns normally if it doesn't contain an infinite loop nor returns abnormally
by throwing, calling @code{abort()} or trapping. This analysis requires option
@option{-fipa-pure-const}, which is enabled by default at @option{-O} and
higher. Higher optimization levels improve the accuracy of the analysis.
@item -Wsuggest-attribute=format
@itemx -Wmissing-format-attribute
@opindex Wsuggest-attribute=format
@opindex Wmissing-format-attribute
@opindex Wno-suggest-attribute=format
@opindex Wno-missing-format-attribute
@opindex Wformat
@opindex Wno-format
Warn about function pointers that might be candidates for @code{format}
attributes. Note these are only possible candidates, not absolute ones.
GCC guesses that function pointers with @code{format} attributes that
are used in assignment, initialization, parameter passing or return
statements should have a corresponding @code{format} attribute in the
resulting type. I.e.@: the left-hand side of the assignment or
initialization, the type of the parameter variable, or the return type
of the containing function respectively should also have a @code{format}
attribute to avoid the warning.
GCC also warns about function definitions that might be
candidates for @code{format} attributes. Again, these are only
possible candidates. GCC guesses that @code{format} attributes
might be appropriate for any function that calls a function like
@code{vprintf} or @code{vscanf}, but this might not always be the
case, and some functions for which @code{format} attributes are
appropriate may not be detected.
@end table
@item -Warray-bounds
@ -4424,29 +4452,6 @@ struct s x = @{ .f = 3, .g = 4 @};
This warning is included in @option{-Wextra}. To get other @option{-Wextra}
warnings without this one, use @option{-Wextra -Wno-missing-field-initializers}.
@item -Wmissing-format-attribute
@opindex Wmissing-format-attribute
@opindex Wno-missing-format-attribute
@opindex Wformat
@opindex Wno-format
Warn about function pointers that might be candidates for @code{format}
attributes. Note these are only possible candidates, not absolute ones.
GCC guesses that function pointers with @code{format} attributes that
are used in assignment, initialization, parameter passing or return
statements should have a corresponding @code{format} attribute in the
resulting type. I.e.@: the left-hand side of the assignment or
initialization, the type of the parameter variable, or the return type
of the containing function respectively should also have a @code{format}
attribute to avoid the warning.
GCC also warns about function definitions that might be
candidates for @code{format} attributes. Again, these are only
possible candidates. GCC guesses that @code{format} attributes
might be appropriate for any function that calls a function like
@code{vprintf} or @code{vscanf}, but this might not always be the
case, and some functions for which @code{format} attributes are
appropriate may not be detected.
@item -Wno-multichar
@opindex Wno-multichar
@opindex Wmultichar