aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authorJoseph Myers <jsm28@cam.ac.uk>2000-10-17 07:52:06 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2000-10-17 07:52:06 +0100
commit74ff46299b5d4b97dc736fc77fb3a2618c119e85 (patch)
tree0d78db7f736f6806e242f06d781a29dd0b8f8ae2 /gcc/c-common.c
parent1d3b0e2c196a53b8d0e0b8ecabf5b110f666c442 (diff)
downloadgcc-74ff46299b5d4b97dc736fc77fb3a2618c119e85.zip
gcc-74ff46299b5d4b97dc736fc77fb3a2618c119e85.tar.gz
gcc-74ff46299b5d4b97dc736fc77fb3a2618c119e85.tar.bz2
c-common.h (warn_missing_format_attribute): New variable.
* c-common.h (warn_missing_format_attribute): New variable. * c-decl.c (warn_missing_format_attribute): New variable. (c_decode_option): Decode -Wmissing-format-attribute and -Wno-missing-format-attribute. * c-common.c (check_function_format): If -Wmissing-format-attribute, give a warning where a vprintf or vscanf function is called by a function without its own printf or scanf attribute. * toplev.c (documented_lang_options): Add -Wmissing-format-attribute. * invoke.texi: Document -Wmissing-format-attribute. cp: * decl2.c (warn_missing_format_attribute): New variable. (lang_decode_option): Decode -Wmissing-format-attribute. testsuite: * gcc.dg/format-miss-1.c: New test. From-SVN: r36897
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 3b88f18..db28750 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -1926,7 +1926,9 @@ record_international_format (name, assembler_name, format_num)
NAME is the function identifier.
ASSEMBLER_NAME is the function's assembler identifier.
(Either NAME or ASSEMBLER_NAME, but not both, may be NULL_TREE.)
- PARAMS is the list of argument values. */
+ PARAMS is the list of argument values. Also, if -Wmissing-format-attribute,
+ warn for calls to vprintf or vscanf in functions with no such format
+ attribute themselves. */
void
check_function_format (status, name, assembler_name, params)
@@ -1946,6 +1948,20 @@ check_function_format (status, name, assembler_name, params)
{
/* Yup; check it. */
check_format_info (status, info, params);
+ if (warn_missing_format_attribute && info->first_arg_num == 0
+ && (format_types[info->format_type].flags & FMT_FLAG_ARG_CONVERT))
+ {
+ function_format_info *info2;
+ for (info2 = function_format_list; info2; info2 = info2->next)
+ if ((info2->assembler_name
+ ? (info2->assembler_name == DECL_ASSEMBLER_NAME (current_function_decl))
+ : (info2->name == DECL_NAME (current_function_decl)))
+ && info2->format_type == info->format_type)
+ break;
+ if (info2 == NULL)
+ warning ("function might be possible candidate for `%s' format attribute",
+ format_types[info->format_type].name);
+ }
break;
}
}