diff options
author | Joseph Myers <jsm28@cam.ac.uk> | 2000-10-17 07:52:06 +0100 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2000-10-17 07:52:06 +0100 |
commit | 74ff46299b5d4b97dc736fc77fb3a2618c119e85 (patch) | |
tree | 0d78db7f736f6806e242f06d781a29dd0b8f8ae2 /gcc/testsuite | |
parent | 1d3b0e2c196a53b8d0e0b8ecabf5b110f666c442 (diff) | |
download | gcc-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/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/format-miss-1.c | 42 |
2 files changed, 46 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c78c097..04e3adb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2000-10-17 Joseph S. Myers <jsm28@cam.ac.uk> + + * gcc.dg/format-miss-1.c: New test. + 2000-10-16 Jakub Jelinek <jakub@redhat.com> * gcc.c-torture/execute/20001013-1.c: New test. diff --git a/gcc/testsuite/gcc.dg/format-miss-1.c b/gcc/testsuite/gcc.dg/format-miss-1.c new file mode 100644 index 0000000..a5d467a --- /dev/null +++ b/gcc/testsuite/gcc.dg/format-miss-1.c @@ -0,0 +1,42 @@ +/* Test for warnings for missing format attributes. */ +/* Origin: Joseph Myers <jsm28@cam.ac.uk> */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -Wformat -Wmissing-format-attribute" } */ + +#include <stdarg.h> + +extern int vprintf (const char *restrict, va_list); +extern int vscanf (const char *restrict, va_list); + +void +foo (const char *fmt, ...) +{ + va_list ap; + va_start (ap, fmt); + vprintf (fmt, ap); /* { dg-warning "candidate" "printf attribute warning" } */ + va_end (ap); +} + +void +bar (const char *fmt, ...) +{ + va_list ap; + va_start (ap, fmt); + vscanf (fmt, ap); /* { dg-warning "candidate" "scanf attribute warning" } */ + va_end (ap); +} + +__attribute__((__format__(__printf__, 1, 2))) void +foo2 (const char *fmt, ...) +{ + va_list ap; + va_start (ap, fmt); + vprintf (fmt, ap); + va_end (ap); +} + +void +vfoo (const char *fmt, va_list arg) +{ + vprintf (fmt, arg); /* { dg-warning "candidate" "printf attribute warning 2" } */ +} |